Skip to content

Commit d7fc501

Browse files
added qos relay for the IMU
1 parent d926b93 commit d7fc501

4 files changed

Lines changed: 38 additions & 31 deletions

File tree

src/hangar_sim/config/control/picknik_ur.ros2_control.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,9 +287,9 @@ imu_sensor_broadcaster:
287287
# Orientation covariance (rad^2)
288288
static_covariance_orientation: [0.001, 0.0, 0.0, 0.0, 0.001, 0.0, 0.0, 0.0, 0.001]
289289
# Angular velocity covariance (rad/s)^2
290-
static_covariance_angular_velocity: [100.0, 0.0, 0.0, 0.0, 100.0, 0.0, 0.0, 0.0, 100.0]
290+
static_covariance_angular_velocity: [0.01, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.01]
291291
# Linear acceleration covariance (m/s^2)^2
292-
static_covariance_linear_acceleration: [0.01, 0.0, 0.0, 0.0, 0.01, 0.0, 0.0, 0.0, 0.01]
292+
static_covariance_linear_acceleration: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
293293

294294

295295
velocity_force_controller:

src/hangar_sim/config/fuse/fuse.yaml

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,10 @@ state_estimator:
1515
mobile_base_motion:
1616
# Process noise for state variables
1717
# Order: x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az
18-
# Ground robot: z, roll, pitch (and their velocities) should be small
19-
# since the robot stays on the ground plane and level.
20-
#trying this with the actual wheel odom
21-
process_noise_diagonal: [0.25, 0.25, 0.001, 0.001, 0.001, 0.25, 0.1, 0.1, 0.001, 0.001, 0.001, 0.1, 0.001, 0.001, 0.001]
22-
#this one works with the ground truth odom
23-
#process_noise_diagonal: [2.0, 2.0, 0.1, 0.1, 0.1, 2.0, 2.0, 1.0, 0.1, 0.1, 0.1, 0.001, 0.01, 0.01, 0.001]
18+
# z, roll, pitch and their derivatives are near-zero for a ground robot.
19+
#process_noise_diagonal: [0.25, 0.25, 0.00001, 0.00001, 0.00001, 0.25
20+
# -, 0.1, 0.1, 0.00001, 0.00001, 0.0001, 0.1, 0.0001, 0.0001, 0.00001]
21+
process_noise_diagonal: [1.0, 1.0, 0.0001, 0.0001, 0.0001, 0.5, 0.5, 0.5, 0.0001, 0.0001, 0.0001, 0.25, 0.00001, 0.00001, 0.00001]
2422

2523
sensor_models:
2624
initial_localization_sensor:
@@ -38,9 +36,11 @@ state_estimator:
3836
publish_on_startup: true
3937
# Order: x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az
4038
initial_state: [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]
41-
initial_sigma: [0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1]
39+
# Order: x, y, z, roll, pitch, yaw, vx, vy, vz, vroll, vpitch, vyaw, ax, ay, az
40+
# z and its derivatives start with very tight sigma — ground robot stays on the plane.
41+
initial_sigma: [0.1, 0.1, 0.001, 0.01, 0.01, 0.1, 0.1, 0.1, 0.001, 0.01, 0.01, 0.1, 0.001, 0.001, 0.001]
4242

43-
# Wheel odometry — differential mode
43+
# Wheel odometry — provides translation (x, y) and yaw
4444
# Using differential mode because platform_velocity_controller/odom is
4545
# wheel-integrated odometry that drifts over time. Differential mode fuses
4646
# only the relative change between consecutive messages, preventing
@@ -56,24 +56,20 @@ state_estimator:
5656
a: 1.0
5757
position_dimensions: ['x', 'y', 'z']
5858
orientation_dimensions: ['yaw']
59-
linear_velocity_dimensions: ['x']
59+
linear_velocity_dimensions: ['x', 'y']
6060
angular_velocity_dimensions: ['yaw']
6161
differential: true
6262
independent: false
6363
use_twist_covariance: true
6464

65-
# IMU sensor
66-
# - Roll/pitch orientation from gravity vector (absolute, keeps robot level)
65+
# IMU sensor — provides orientation and yaw rate
66+
# - Roll/pitch/yaw orientation (absolute, covariance 0.001 vs wheel odom 0.5)
6767
# - Yaw angular velocity from gyroscope
68-
# - Z linear acceleration (gravity-compensated, constrains vertical dynamics)
6968
imu_sensor:
70-
topic: /imu_sensor_broadcaster/imu
71-
orientation_dimensions: ['roll', 'pitch']
69+
topic: /imu_sensor_broadcaster/imu_reliable
70+
orientation_dimensions: ['roll', 'pitch', 'yaw']
7271
angular_velocity_dimensions: ['yaw']
73-
linear_acceleration_dimensions: ['z']
74-
remove_gravitational_acceleration: true
7572
queue_size: 10
76-
throttle_period: 0.1
7773

7874
# Publish filtered odometry
7975
publishers:

src/hangar_sim/launch/sim/robot_drivers_to_persist_sim.launch.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -268,11 +268,11 @@ def generate_launch_description():
268268
arguments=["0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "map", "odom"],
269269
)
270270

271-
# QoS relay to bridge BEST_EFFORT odom to RELIABLE for fuse
272-
odom_qos_relay = Node(
271+
# QoS relay to bridge BEST_EFFORT odom and IMU to RELIABLE for fuse
272+
sensor_qos_relay = Node(
273273
package="hangar_sim",
274274
executable="odom_qos_relay.py",
275-
name="odom_qos_relay",
275+
name="sensor_qos_relay",
276276
output="log",
277277
)
278278

@@ -304,7 +304,7 @@ def generate_launch_description():
304304

305305
ld.add_action(static_tf_world_to_map)
306306
ld.add_action(static_tf_map_to_odom)
307-
ld.add_action(odom_qos_relay)
307+
ld.add_action(sensor_qos_relay)
308308

309309
# Fuse state estimator for mobile base localization
310310
hangar_sim_pkg = FindPackageShare("hangar_sim")

src/hangar_sim/script/odom_qos_relay.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,13 @@
2828
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2929
# POSSIBILITY OF SUCH DAMAGE.
3030

31-
"""Relay node to bridge BEST_EFFORT odometry to RELIABLE QoS for fuse."""
31+
"""Relay node to bridge BEST_EFFORT sensor topics to RELIABLE QoS for fuse."""
3232

3333
import rclpy
3434
from rclpy.node import Node
3535

3636
from nav_msgs.msg import Odometry
37+
from sensor_msgs.msg import Imu
3738

3839
from rclpy.qos import (
3940
QoSProfile,
@@ -43,11 +44,11 @@
4344
)
4445

4546

46-
class OdomQoSRelay(Node):
47-
"""Relay node that subscribes to odometry with BEST_EFFORT and republishes with RELIABLE QoS."""
47+
class SensorQoSRelay(Node):
48+
"""Relay node that subscribes to sensor topics with BEST_EFFORT and republishes with RELIABLE QoS."""
4849

4950
def __init__(self):
50-
super().__init__("odom_qos_relay")
51+
super().__init__("sensor_qos_relay")
5152

5253
# Subscribe with BEST_EFFORT to match mujoco_system publisher
5354
qos_sub = QoSProfile(
@@ -65,18 +66,28 @@ def __init__(self):
6566
depth=10,
6667
)
6768

68-
self.sub = self.create_subscription(
69+
# Odometry relay
70+
self.odom_sub = self.create_subscription(
6971
Odometry, "/odom", self.odom_callback, qos_sub
7072
)
71-
self.pub = self.create_publisher(Odometry, "/odom_reliable", qos_pub)
73+
self.odom_pub = self.create_publisher(Odometry, "/odom_reliable", qos_pub)
74+
75+
# IMU relay
76+
self.imu_sub = self.create_subscription(
77+
Imu, "/imu_sensor_broadcaster/imu", self.imu_callback, qos_sub
78+
)
79+
self.imu_pub = self.create_publisher(Imu, "/imu_sensor_broadcaster/imu_reliable", qos_pub)
7280

7381
def odom_callback(self, msg):
74-
self.pub.publish(msg)
82+
self.odom_pub.publish(msg)
83+
84+
def imu_callback(self, msg):
85+
self.imu_pub.publish(msg)
7586

7687

7788
def main(args=None):
7889
rclpy.init(args=args)
79-
node = OdomQoSRelay()
90+
node = SensorQoSRelay()
8091
rclpy.spin(node)
8192
node.destroy_node()
8293
rclpy.shutdown()

0 commit comments

Comments
 (0)