davidmball / ratslam

Automatically exported from code.google.com/p/ratslam
GNU General Public License v3.0
151 stars 58 forks source link

Hi, could you please tell me how to add one more ros node for ratslam? #18

Open sunt40 opened 4 years ago

scott-- commented 4 years ago

What is the purpose of adding another node? You can add a new ROS node in the same way as any other ROS system (https://wiki.ros.org/ROSNodeTutorialC++).

sunt40 commented 4 years ago

Make ratslam subscribe one more node, such as semantic information node, to improve its map accuracy.But I don't know how to add ROS nodes for ratslam.

scott-- commented 4 years ago

You can subscribe to any of the RatSLAM topics. E.g.,

import rospy
from ratslam_ros.msg import TopologicalMap

rospy.init_node("ratslam_map_subscriber")

def on_receive_map(map):
    print(map)

sub_ratslam_map = rospy.Subscriber(
  "/irat_red/ExperienceMap/Map",
  TopologicalMap, 
  on_receive_map
)

rospy.spin()

Note in this case RatSLAM only writes the map out at 30 second intervals. You might want to change this line "if (action->header.stamp - prev_pub_time > ros::Duration(30.0))" to set a different duration.

There is a lot of info in our OpenRatSLAM paper about the software architecture (search Google scholar for OpenRatSLAM). Fig. 2 in our OpenRatSLAM paper shows the ROS connections between nodes by message type and descriptions of messages. You can also run rostopic info while RatSLAM is running to get a list of the topics used in the system.

sunt40 commented 4 years ago

I think I need to modify and add some node names which ratslam subscribes.Which files should I modify?

sunt40 commented 4 years ago

Can you give me your email or other contact information for the convenience of communication. Recently I have some problem about ratslam and I'm sure you can give me a lot of help. @scott--

scott-- commented 4 years ago

All the ROS interfaces are in the main*.cpp files.

You can do a search for subscriptions and publishing like this.

grep -E -R -n "subscribe[\(|\<].*\)" .

./ratslam_ros/src/main_em.cpp:279: ros::Subscriber sub_odometry = node.subscribe(topic_root + "/odom", 0, boost::bind(odo_callback, _1, em), ros::VoidConstPtr(), ./ratslam_ros/src/main_em.cpp:281: ros::Subscriber sub_action = node.subscribe(topic_root + "/PoseCell/TopologicalAction", 0, boost::bind(action_callback, _1, em), ./ratslam_ros/src/main_em.cpp:284: ros::Subscriber sub_goal = node.subscribe(topic_root + "/ExperienceMap/SetGoalPose", 0, boost::bind(set_goal_pose_callback, _1, em), ./ratslam_ros/src/main_lv.cpp:112: image_transport::Subscriber sub = it.subscribe(topic_root + "/camera/image", 0, boost::bind(image_callback, _1, &pub_vt)); ./ratslam_ros/src/main_pc.cpp:134: ros::Subscriber sub_odometry = node.subscribe(topic_root + "/odom", 0, boost::bind(odo_callback, _1, pc, &pub_pc), ros::VoidConstPtr(), ./ratslam_ros/src/main_pc.cpp:136: ros::Subscriber sub_template = node.subscribe(topic_root + "/LocalView/Template", 0, boost::bind(template_callback, _1, pc, &pub_pc), ./ratslam_ros/src/main_vo.cpp:99: image_transport::Subscriber sub = it.subscribe(topic_root + "/camera/image", 1, image_callback);

grep -E -R -n "advertise[\(|\<].*\)" .

./ratslam_ros/src/main_em.cpp:272: pub_em = node.advertise(topic_root + "/ExperienceMap/Map", 1); ./ratslam_ros/src/main_em.cpp:273: pub_em_markers = node.advertise(topic_root + "/ExperienceMap/MapMarker", 1); ./ratslam_ros/src/main_em.cpp:275: pub_pose = node.advertise(topic_root + "/ExperienceMap/RobotPose", 1); ./ratslam_ros/src/main_em.cpp:277: pub_goal_path = node.advertise(topic_root + "/ExperienceMap/PathToGoal", 1); ./ratslam_ros/src/main_lv.cpp:109: ros::Publisher pub_vt = node.advertise(topic_root + "/LocalView/Template", 0); ./ratslam_ros/src/main_pc.cpp:132: ros::Publisher pub_pc = node.advertise(topic_root + "/PoseCell/TopologicalAction", 0); ./ratslam_ros/src/main_vo.cpp:96: pub_vo = node.advertise(topic_root + "/odom", 0);

Can you give me your email or other contact information for the convenience of communication.

All of these comments get emailed to me already, but as I am not currently working in this space, I only answer them when I get time.

sunt40 commented 4 years ago

OK.Thank you very much.

sunt40 commented 4 years ago

I want ratslam's experience map node to subscribe to an extra topic . How to change it in main_em.cpp ?

scott-- commented 4 years ago

Subscribing to another topic is exactly the same as standard ROS. You would just add the following: void callback(MsgTypeConstPtr msg, other_arguments ...) { }

Then inside main(): ros::Subscriber sub_new_topic = node.subscribe<MsgType>(topic, 0, boost::bind(callback, _1, other_arguments ...), ros::VoidConstPtr());

You'll need to lookup the ROS tutorials for message generation, boost::bind, etc

sunt40 commented 4 years ago

OK. Thank you a lot!