Skip to content

Commit

Permalink
fixed imu orientation
Browse files Browse the repository at this point in the history
  • Loading branch information
joel-mb committed Nov 15, 2023
1 parent e631607 commit 6b7db44
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions carla_ros_bridge/src/carla_ros_bridge/imu.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,10 @@ def sensor_data_updated(self, carla_imu_measurement):
imu_msg.linear_acceleration.y = -carla_imu_measurement.accelerometer.y
imu_msg.linear_acceleration.z = carla_imu_measurement.accelerometer.z

quat = euler2quat(math.sin(-carla_imu_measurement.compass), math.cos(-carla_imu_measurement.compass), 0.0)
quat = euler2quat(0.0, 0.0, (math.pi / 2.0) - carla_imu_measurement.compass)
imu_msg.orientation.w = quat[0]
imu_msg.orientation.x = quat[1]
imu_msg.orientation.y = quat[2]
imu_msg.orientation.z = quat[3]

roll, pitch, yaw = quat2euler([
imu_msg.orientation.w,
imu_msg.orientation.x,
imu_msg.orientation.y,
imu_msg.orientation.z])
compass = -math.atan2(roll, pitch) + 2*math.pi

self.imu_publisher.publish(imu_msg)

0 comments on commit 6b7db44

Please sign in to comment.