microsoft / Azure_Kinect_ROS_Driver

A ROS sensor driver for the Azure Kinect Developer Kit.
MIT License
304 stars 226 forks source link

kinect_rgbd launch file does not parse sensor_sn properly #264

Open TheodoroCardoso opened 1 year ago

TheodoroCardoso commented 1 year ago

Describe the bug As opposed to driver.launch which actually uses the correct serial number (sensor_sn parameter), the kinect_rgbd.launch file seems to ignore it, even though it's passed into the k4a_ros_bridge nodelet

To Reproduce roslaunch azure_kinect_ros_driver kinect_rgbd.launch sensor_sn:=999

Expected behavior Parse the parameter properly, print it, and launch the camera that has the provided serial number when multiple devices are connected.

Desktop (please complete the following information):

Additional context roslaunch azure_kinect_ros_driver driver.launch sensor_sn:=999 Prints:

[ INFO] [1672839922.394529610]: K4A Parameters:
[ INFO] [1672839922.395489727]: sensor_sn - std::string : 999

roslaunch azure_kinect_ros_driver kinect_rgbd.launch sensor_sn:=999 Prints:

[ INFO] [1672839906.401629522]: K4A ROS Nodelet Start
[ INFO] [1672839906.429111080]: K4A Parameters:
[ INFO] [1672839906.429242463]: sensor_sn - std::string : 
farazxavor commented 1 year ago

Hello Theo,

You need to specify the type of the sensor_sn param on line 96 as follows

<param name="sensor_sn" type="string" value="$(arg sensor_sn)" />

For some reason, the sensor_sn parameter doesn't get parsed in C++ code without specifying the argument type.

TheodoroCardoso commented 1 year ago

Hey farazxavor,

This indeed does the trick.

Just tested it with real hardware. Here's my fork with type added to all params just like in driver.launch https://github.com/microsoft/Azure_Kinect_ROS_Driver/compare/melodic...TheodoroCardoso:Azure_Kinect_ROS_Driver:melodic

Thanks for pointing that out!

Pempafugue commented 1 year ago

Hello, So I have been struggling with this problem too on Ubuntu 22.04 I first tried to use sensor_sn_value = ParameterValue(value=LaunchConfiguration('sensor_sn'), value_type=str) And it worked fine for a serial number, but when I tried for 001087594512 somehow, I get the error that I am sending a double to the node. It may be cause by the way python process numbers starting by 00 in the background, converting them into double. My workaround is to add a letter to the string, such as S001087594512 and add if(params_.sensor_sn != ""){ params_.sensor_sn.erase(0, 1); } in the k4a_ros_device.cpp, and it works fine