Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sunt40 opened this issue Sep 19, 2019 · 10 comments
Open

Comments

@sunt40
Copy link

sunt40 commented Sep 19, 2019

No description provided.

@scott--
Copy link
Collaborator

scott-- commented Sep 21, 2019

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
Copy link
Author

sunt40 commented Sep 22, 2019

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--
Copy link
Collaborator

scott-- commented Sep 22, 2019

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
Copy link
Author

sunt40 commented Sep 23, 2019

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

@sunt40
Copy link
Author

sunt40 commented Oct 7, 2019

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--
Copy link
Collaborator

scott-- commented Oct 8, 2019

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<nav_msgs::Odometry>(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<ratslam_ros::TopologicalAction>(topic_root + "/PoseCell/TopologicalAction", 0, boost::bind(action_callback, _1, em),
./ratslam_ros/src/main_em.cpp:284: ros::Subscriber sub_goal = node.subscribe<geometry_msgs::PoseStamped>(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<nav_msgs::Odometry>(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<ratslam_ros::ViewTemplate>(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<ratslam_ros::TopologicalMap>(topic_root + "/ExperienceMap/Map", 1);
./ratslam_ros/src/main_em.cpp:273: pub_em_markers = node.advertise<visualization_msgs::Marker>(topic_root + "/ExperienceMap/MapMarker", 1);
./ratslam_ros/src/main_em.cpp:275: pub_pose = node.advertise<geometry_msgs::PoseStamped>(topic_root + "/ExperienceMap/RobotPose", 1);
./ratslam_ros/src/main_em.cpp:277: pub_goal_path = node.advertise<nav_msgs::Path>(topic_root + "/ExperienceMap/PathToGoal", 1);
./ratslam_ros/src/main_lv.cpp:109: ros::Publisher pub_vt = node.advertise<ratslam_ros::ViewTemplate>(topic_root + "/LocalView/Template", 0);
./ratslam_ros/src/main_pc.cpp:132: ros::Publisher pub_pc = node.advertise<ratslam_ros::TopologicalAction>(topic_root + "/PoseCell/TopologicalAction", 0);
./ratslam_ros/src/main_vo.cpp:96: pub_vo = node.advertise<nav_msgs::Odometry>(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
Copy link
Author

sunt40 commented Oct 10, 2019

OK.Thank you very much.

@sunt40
Copy link
Author

sunt40 commented Oct 18, 2019

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

@scott--
Copy link
Collaborator

scott-- commented Nov 2, 2019

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
Copy link
Author

sunt40 commented Nov 4, 2019

OK. Thank you a lot!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants