Skip to content

Commit 1fcd6d9

Browse files
committed
remove the scan_mirror_fix and change mujoco plugin to handle the 180 roll
1 parent 950aa80 commit 1fcd6d9

6 files changed

Lines changed: 34 additions & 108 deletions

File tree

src/hangar_sim/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ pluginlib_export_plugin_description_file(
2525
install(PROGRAMS
2626
script/odometry_joint_state_publisher.py
2727
script/odom_qos_relay.py
28-
script/scan_mirror_fix.py
2928
DESTINATION lib/${PROJECT_NAME}
3029
)
3130

src/hangar_sim/description/ur5e_ridgeback.xml

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,12 @@
211211
<body name="base_platform" pos="0 0 0" euler="0 0 0">
212212
<body name="ridgeback_base_link">
213213
<!-- Front SICK TIM571: mounted at x=+0.45m (front bumper), z=0.15m.
214-
91 beams x 3 deg = 270 deg FOV, sweeping CCW from beam-0 at -135 deg.
215-
quat="0.6533 0.2706 -0.6533 0.2706": beam-0 +Z fires at -135 deg from +X. -->
214+
91 beams x 3 deg = 270 deg FOV, sweeping CCW from beam-0 at -135 deg in robot frame.
215+
Quat rule: site Z axis = beam-0 firing direction. Site X axis must point in world -Z
216+
so the plugin's Rot(-90,Y) produces a Z-up _ROS frame.
217+
Formula: R_base = Rot_Z(phi) * Rot_Y(+90 deg), where phi = beam-0 robot-frame angle.
218+
Front: phi=-135 deg -> R_base = Rot_Z(-135)*Rot_Y(90) -> quat=(0.2706,0.6533,0.2706,-0.6533).
219+
angle_min=0 in rangefinder user params so the plugin sets _ROS frame X = beam-0 direction. -->
216220
<body name="lidar_front_mount" pos="0.45 0 0.15">
217221
<inertial
218222
mass="0.25"
@@ -224,7 +228,7 @@
224228
name="lidar_front"
225229
size="0.01"
226230
pos="0 0 0"
227-
quat="0.6533 0.2706 -0.6533 0.2706"
231+
quat="0.2706 0.6533 0.2706 -0.6533"
228232
/>
229233
</replicate>
230234
<!-- TIM571 body: dark cylinder, visual-only -->
@@ -252,8 +256,9 @@
252256
</body>
253257

254258
<!-- Rear SICK TIM571: mounted at x=-0.45m (rear bumper), z=0.15m.
255-
91 beams x 3 deg = 270 deg FOV, sweeping CCW from beam-0 at +45 deg.
256-
quat="0.2706 -0.6533 -0.2706 -0.6533": beam-0 +Z fires at +45 deg from +X. -->
259+
91 beams x 3 deg = 270 deg FOV, sweeping CCW from beam-0 at +45 deg in robot frame.
260+
Rear: phi=+45 deg -> R_base = Rot_Z(45)*Rot_Y(90) -> quat=(0.6533,-0.2706,0.6533,0.2706).
261+
angle_min=0 in rangefinder user params so the plugin sets _ROS frame X = beam-0 direction. -->
257262
<body name="lidar_rear_mount" pos="-0.45 0 0.15">
258263
<inertial
259264
mass="0.25"
@@ -265,7 +270,7 @@
265270
name="lidar_rear"
266271
size="0.01"
267272
pos="0 0 0"
268-
quat="0.2706 -0.6533 -0.2706 -0.6533"
273+
quat="0.6533 -0.2706 0.6533 0.2706"
269274
/>
270275
</replicate>
271276
<!-- TIM571 body: dark cylinder, visual-only -->
@@ -669,15 +674,12 @@
669674
<framequat objtype="site" objname="imu_site" />
670675
<gyro site="imu_site" />
671676
<accelerometer site="imu_site" />
672-
<!-- Front TIM571: 270 deg FOV, 3 deg resolution (91 beams), 0.05-25m range -->
673-
<rangefinder
674-
site="lidar_front"
675-
user="0.05 -2.35619 2.35619 0.05236 0.05 25.0"
676-
/>
677-
<!-- Rear TIM571: same specs, mounted facing backward for 360 deg coverage -->
678-
<rangefinder
679-
site="lidar_rear"
680-
user="0.05 -2.35619 2.35619 0.05236 0.05 25.0"
681-
/>
677+
<!-- Front TIM571: 270 deg FOV, 3 deg resolution (91 beams), 0.05-25m range.
678+
angle_min=0 so the _ROS frame X axis points at beam-0 (per plugin convention).
679+
The sweep is 0 to 4.7124 rad (270 deg) in the sensor frame, which maps to
680+
beam-0 at -135 deg and beam-90 at +135 deg in the robot frame. -->
681+
<rangefinder site="lidar_front" user="0.05 0.0 4.7124 0.05236 0.05 25.0" />
682+
<!-- Rear TIM571: same convention — angle_min=0, frame X points at beam-0 (+45 deg robot frame). -->
683+
<rangefinder site="lidar_rear" user="0.05 0.0 4.7124 0.05236 0.05 25.0" />
682684
</sensor>
683685
</mujoco>

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

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -286,17 +286,8 @@ def generate_launch_description():
286286

287287
hangar_sim_pkg = FindPackageShare("hangar_sim")
288288

289-
# Reverses the ranges array in /scan to correct the Y-axis flip caused by the
290-
# MuJoCo lidar plugin's 180-deg roll in the lidar_*_ROS TF frames.
291-
scan_mirror_fix = Node(
292-
package="hangar_sim",
293-
executable="scan_mirror_fix.py",
294-
name="scan_mirror_fix",
295-
output="log",
296-
)
297-
298-
# Angular bounds filter: clips chassis self-hitting beams (±93° to ±135°) from
299-
# /scan_mirrored, publishes clean scan to /scan_filtered for Nav2 costmap.
289+
# Angular bounds filter: clips chassis self-hitting beams (±93° to ±135°),
290+
# publishes clean scan to /scan_filtered for Nav2 costmap.
300291
laser_filter_node = Node(
301292
package="laser_filters",
302293
executable="scan_to_scan_filter_chain",
@@ -306,11 +297,7 @@ def generate_launch_description():
306297
[hangar_sim_pkg, "params", "laser_filter_params.yaml"]
307298
),
308299
{"use_sim_time": use_sim_time},
309-
{"qos_overrides./scan_mirrored.subscription.reliability": "best_effort"},
310-
],
311-
remappings=[
312-
("scan", "/scan_mirrored"),
313-
("scan_filtered", "/scan_filtered"),
300+
{"qos_overrides./scan.subscription.reliability": "best_effort"},
314301
],
315302
output="log",
316303
)
@@ -356,7 +343,6 @@ def generate_launch_description():
356343
ld.add_action(static_tf_map_to_odom)
357344
ld.add_action(odom_to_joint_state_repub)
358345
ld.add_action(odom_qos_relay)
359-
ld.add_action(scan_mirror_fix)
360346
ld.add_action(laser_filter_node)
361347
ld.add_action(fuse_state_estimator)
362348

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
# Angular bounds filter for the dual SICK TIM571 lidars.
22
#
3-
# Both lidars (lidar_front_ROS and lidar_rear_ROS) publish to /scan.
4-
# Each covers -135 deg to +135 deg. Beams from +/-93 deg to +/-135 deg
5-
# point backward past the chassis edges and produce self-hits.
3+
# Both lidars publish to /scan with angle_min=0 and angle_max=4.7124 (270 deg sweep).
4+
# The lidar _ROS frame X axis points at beam-0, so scan angle alpha maps to robot frame
5+
# angle (alpha + frame_yaw):
6+
# front lidar frame yaw = -135 deg: robot angle = scan_angle - 135 deg
7+
# rear lidar frame yaw = +45 deg: robot angle = scan_angle + 45 deg
68
#
7-
# This filter keeps only beams within +/-93 deg (-1.6231 to 1.6231 rad),
8-
# removing the self-hitting beams at the edges. Combined, both lidars
9-
# give 360 deg coverage.
9+
# Chassis self-hits occur when |robot_frame_angle| > 90 deg, i.e. beams looking more
10+
# than 90 deg backward. This maps to scan angles 0-45 deg and 225-270 deg for both lidars.
11+
# Keeping scan angles 45-225 deg (0.7854 to 3.9270 rad) eliminates all self-hits and
12+
# gives each lidar a clean 180 deg arc; combined they cover 360 deg.
1013
laser_angular_filter:
1114
ros__parameters:
1215
filter1:
1316
name: angular_bounds
1417
type: laser_filters/LaserScanAngularBoundsFilter
1518
params:
16-
lower_angle: -1.6231
17-
upper_angle: 1.6231
19+
lower_angle: 0.7854
20+
upper_angle: 3.9270

src/hangar_sim/params/nav2_params.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,8 +235,8 @@ controller_server:
235235
local_costmap:
236236
local_costmap:
237237
ros__parameters:
238-
update_frequency: 5.0
239-
publish_frequency: 2.0
238+
update_frequency: 10.0
239+
publish_frequency: 5.0
240240
global_frame: odom
241241
robot_base_frame: ridgeback_base_link
242242
use_sim_time: True

src/hangar_sim/script/scan_mirror_fix.py

Lines changed: 0 additions & 64 deletions
This file was deleted.

0 commit comments

Comments
 (0)