IMUSensor Data with specified frequency

Hi,

I am trying to obtain IMU sensor data at a constant frequency of 50Hz i.e 50 data points for per second. After reading the docs and doing my best to understand them, I have reached to the conclusion that I should be using a fixed time-step for repeatability (still using the default Asynchronous mode) while varying the sensor_tick for the IMU sensor itself to achieve the 50Hz I require.

So I have set the sensor_tick to 1/50 = 0.02 and the fixed_delta_seconds to a constant 0.5.

I have created the IMU Sensor as was done in the manual_control.py example but unfortunately my understanding isn’t sound since the sensor_tick does not effect the frequency of the data collection. Only when changing the fixed_delta_seconds to 0.02 does the IMU sensor be called 50 times a second. This results in a unrealistically slow simulation and high IMU sensor values (don’t know the reason for this either). I have also tried enabling -no-rendering with no luck. Below I have included the IMU Class code.

class CustomImuSensor(object):

def __init__(self, parent_actor):
    self.sensor = None
    self._parent = parent_actor
    self.accelerometer = (0.0, 0.0, 0.0)
    self.gyroscope = (0.0, 0.0, 0.0)
    self.compass = 0.0
    world = self._parent.get_world()
    bp = world.get_blueprint_library().find('sensor.other.imu')
    bp.set_attribute("sensor_tick",str(0.02))
    print("IMU2" + str(bp.get_attribute("sensor_tick")))
    self.sensor = world.spawn_actor(bp, carla.Transform(), attach_to=self._parent)
    self.sensor.listen(lambda sensor_data: CustomImuSensor.custom_IMU_callback(sensor_data))


@staticmethod
def custom_IMU_callback(sensor_data):
    print("IMU2")
    array_mani2.add_imu_data(sensor_data,sensor_data.timestamp,0,sensor_data.frame)

Would anyone know where my understanding is flawed? I have a low-end machine but I’m not quite sure if this should have any effect.

    1. List item

Thank you for any help.
Daniel