StanfordVL / iGibson

A Simulation Environment to train Robots in Large Realistic Interactive Scenes
http://svl.stanford.edu/igibson
MIT License
661 stars 159 forks source link

KeyError: 'scan_link' #369

Closed psykaunot closed 2 weeks ago

psykaunot commented 1 month ago

Hello, I am trying to use your package with ROS and a LoCoBot wx250s (which is different from the one in your example). However, I'm having an issue that I am unable to fix.

I have this every time:

logger.warn(f"Box bound precision lowered by casting to {self.dtype}") Traceback (most recent call last): File "/home/trail_ws/src/trailmain/locobot_rgbd.py", line 199, in <module> node = LocobotSimNode() File "/home/trail_ws/src/trailmain/locobot_rgbd.py", line 49, in __init__ self.env = iGibsonEnv( File "/home/trail_ws/src/iGibson/igibson/envs/igibson_env.py", line 64, in __init__ super(iGibsonEnv, self).__init__( File "/home/trail_ws/src/iGibson/igibson/envs/env_base.py", line 108, in __init__ self.load() File "/home/trail_ws/src/iGibson/igibson/envs/igibson_env.py", line 268, in load self.load_observation_space() File "/homes/trail_ws/src/iGibson/igibson/envs/igibson_env.py", line 239, in load_observation_space sensors["scan_occ"] = ScanSensor(self, scan_modalities, laser_link_name=self.laser_link_name) File "/home/trail_ws/src/iGibson/igibson/sensors/scan_sensor.py", line 37, in __init__ env.robots[0].links[self.laser_link_name].get_position_orientation() KeyError: 'scan_link' Waiting for subscriber to connect to /cmd_vel [locobot_sim-4] process has died [pid 1463511, exit code 1, cmd /home/trail_ws/src/trailmain/locobot_rgbd.py /mobile_base/commands/velocity:=/cmd_vel __name:=locobot_sim __log:=/home/.ros/log/4c0a4e08-7f15-11ef-ab16-f51fce83dd60/locobot_sim-4.log]. log file: /home/.ros/log/4c0a4e08-7f15-11ef-ab16-f51fce83dd60/locobot_sim-4*.log

I try to investigate the URDF file of the robot that I generated from the URDF.XACRO of this file https://github.com/Interbotix/interbotix_ros_rovers/blob/main/interbotix_ros_xslocobots/interbotix_xslocobot_descriptions/urdf/locobot.urdf.xacro.

In the pyhton file I created for the locoobt, I made sure to change 'scan_link' to 'locobot/laser_frame_link' but also in the 'scan_sensor.py' file.

psykaunot commented 2 weeks ago

Firstly, to explain how I fixed it, I need to say that I generated an urdf file from the original urdf.xacro of the LoCobot. In this file, the frame_id for the lidar is locobot/laser_frame_link. When I was using it in my yaml and custom py file to launch the robot in iGibson it wasn't working.

I went into the scan_sesnor.py and added those lines just after the self.laser_link_name in the def init of the class ScanSensor print("Laser Link Name in ScanSensor:", self.laser_link_name)

print("Available Robot Links in ScanSensor:", list(env.robots[0].links.keys()))

The result gave me several links and a lot corresponded to only a few links in my urdf file. Available Robot Links in ScanSensor: ['base_footprint', 'base_link', 'wheel_left_link', 'wheel_right_link', 'caster_front_link', 'caster_back_link', 'gyro_link', 'cliff_sensor_left_link', 'cliff_sensor_right_link', 'cliff_sensor_front_link', 'plate_1', 'plate_2', 'arm_base_link', 'shoulder_link', 'elbow_link', 'forearm_link', 'wrist_link', 'gripper_link', 'finger_r', 'finger_l', 'ar_tag', 'cam_mount', 'head_pan_link', 'head_tilt_link', 'camera_link', 'eyes']

I believe that when iGibson loads an urdf file, some of the link names may change. In this list of link name I tried the one that looked to be related the frame_id of the robot scanner, such as in this picture image

Consequently, I picked cam_mount because it seemed closest to locobot/camera_tower_link. So, in my yaml file, my py file and the scan_sensor file, I replaced all the "scan_link" with "cam_mount". It fixed the issue and allowed me to open iGibson and receive images in Rviz.

However, in Rviz the locobot/scan topic wasn't working because now it was associated to the cam_mount frame_id while in is urdf it has locobot/laser_frame_link. The locobot/scan topic also gave scanner values when listening to the topic. Since the urdf was generated from the original urdf.xacro, I took the liberty to change all the locobot/laser_frame_link to cam_mount, which solved the issue and allowed me to have the scanner data in Rviz.