Skip to content
Jakob Auer edited this page Jun 15, 2018 · 4 revisions

Rosbridge

The rosbridge transport allows the connection of a madara/gams system to a running ROS master. It provides communication in both directions - so ROS messages are subscribed and the results are added to the knowledgebase as well as changes to the knowledgebase result in the publication of ROS messages.

How to configure a rosbridge

Since the rosbridge is based on the madara::transport protocol you simply have to add the bridge to you knowledgebase. To do so you also have to define the mapping. This declares which ros topic is mapped to which madara variable name as well as which ros message type shall be used for publication.

See the following example:


  std::vector<std::string> selected_topics {"odom", "/tf", "imu"};
  std::map<std::string,std::string> topic_map = {{"odom", "sensors.odom"},
                                                 {"imu", "sensors.imu"},
                                                 {"/tf", "frames"}};
  std::map<std::string,std::string> pub_types = {{"odom", "nav_msgs/Odometry"},
                                                 {"imu", "sensor_msgs/Imu"}};

  gams::transports::RosBridge * ros_bridge = new gams::transports::RosBridge (
    knowledge.get_id (), settings, knowledge, selected_topics,
    topic_map, pub_types);
  knowledge.attach_transport (ros_bridge);

This example subscribes to odom, imu and /tf and maps it to the names which are defined in topic_map. The map pub_types defines the topic type for each topic in it's string representation.

Important: Please keep in mind that it is necessary to use global variable names for the values you want to publish to ROS when the knowledgebase changes. E.g. if you map imu to .sensors.imu instead of sensors.imu this madara variable would be updated by ROS messages to imu. But since it is defined as local variable it would not be published if the knowledgbase is changed.

Clone this wiki locally