AprilRobotics / apriltag_ros

A ROS wrapper of the AprilTag 3 visual fiducial detector
Other
362 stars 338 forks source link

Added support for multiple camera #85

Closed Nosille closed 1 year ago

Nosille commented 3 years ago

I have RTABMAP setup on my robot using multiple cameras, but when I tried to incorporate apriltags, I ran into an issue where apriltag_ros can only subscribe to one camera, and rtabmap can only subscribe to one tag_detector. Therefore, I modified the apriltag code to subscribe to a list of camera topics and publish all detections on the same topic. The modified code runs each camera in its own thread with a mutex around the code that merges them into a single topic.

I am new to github and pull requests, let me know if I am doing something wrong, but I think this addition could help others.

christian-rauch commented 2 years ago

Wouldn't it be easier to run individual AprilTag nodes/nodelets in parallel, each subscribing to an individual camera?

Nosille commented 2 years ago

I tried that, but it didn't work. RTABMAP is running a message filter to sync all input topics. The result is that it takes whichever apriltag publisher is the most in-sync with the other inputs and ignores the rest. The only way to get it to use all of the apriltag info is to put the data in a single message.

christian-rauch commented 2 years ago

The entire pipeline is not yet clear to me. If you individually sync multiple cameras with their apriltag_ros node {(cam1,tag1), (cam2, tag2), ...}, then this should be synchronised. If you want to sync multiple apriltag_ros outputs (tag1, tag2, ...), you can remap the topics and should be able to sync them too.

Nosille commented 2 years ago

I am trying to work within the existing framework of RTABMAP. It can subscribe to 4 rgbd cameras, but only 1 tag detection topic. Multiple publishers on a single topic does not work due to the way the message filter works (see previous message). Subscribing to multiple topics does not work without modifying RTABMAP, and I don't want to go there because it would require a lot of changes. RTABMAP is wrapped around a database, and the database is very rigid in the data structure. Adding an input to the database comes will all kinds of issues including backward compatibility. Making apriltag_ros connect to multiple cameras and publish the results as a single message was an easy solution that worked within the existing message format published by the node (no issues with backwards compatibility).

christian-rauch commented 2 years ago

Which topics do you need to synchronise? Could you not just synchronise the tag topics into a single "synchronised tag topic" and send this to RTABMAP?

Nosille commented 2 years ago

What tools would you use to merge multiple tag topics into a single tag topic?

christian-rauch commented 2 years ago

What tools would you use to merge multiple tag topics into a single tag topic?

You can use the standard API for synchronising topics (message_filters) and the publish those synchronised messages again on a topic of your choice.