How to use a custom laser scan message for gmapping? I am using YD LIDAR. Can I publish the scan message to another rostopic than /scan?
Publishing the custom message to the same topic is not appropriate, and if I publish to another topic, how can I use it for gmappping and navigation package?
2 Answers
You would need to change the actual gmapping repo or create a node to convert from you custom message type to sensor_msgs::LaserScan. Because if it is a custom message, the void laserCallback(const sensor_msgs::LaserScan::ConstPtr& scan) from the node won't be able to handle.
Mapping to another topic can be achieved by doing remap, either in the launch file of the laserscan publisher or the subscriber
What exactly do you mean by custom laser scan message? A custom message type or just another topic with a sensor_msgs::LaserScan.
If you really mean a custom type and you use ros2, then you can probably use the new TypeAdapter Feature. If you use an older version then you have to convert the message to a known format like sensor_msgs::LaserScan or sensor_msgs::PointCloud2.
If you just have a second scanner and would like to use this data as well, then have a look at one of my questions on ros answers. You can use ira_laser_tools to merge scans into one new scan message or a combined point cloud, but unfortunately, there isn't a great solution. To my knowledge ros_cartographer is currently the only slam package that can handle multiple scanners as input.