I am trying to create a home service robot using a turtlebot. In it the robot should start at origin at travel to point 1 where a marker has been displayed, stay there for 5 seconds and the marker will disappear indicating pick up and then travel to point 2 and stay there for 5 seconds after which marker would reappear indicating drop.
After launching my robot, I cannot view the marker at point 1, but my code for marker is functioning and the robot travels to point 1 and the terminal indicates me of a pickup and then it travels to point 2 where the terminal is indicating drop off and I can see then see the marker. Can someone please explain why am I not able to see the marker at point 1 as well?
The primary problem is in the add_markers.cpp
file as it is the main file which is publishing the markers, on running a rostopic echo on /visualization_marker
topic, I found that for the point A it is not publishing any information but it is doing so for point B which is perplexing me.
My workspace and add_markers.cpp
code.
Originally posted by gentle_yeti on ROS Answers with karma: 3 on 2022-10-19
Post score: 0
Original comments
Comment by ravijoshi on 2022-10-21:
I suggest creating and sharing a minimal reproducible example.
Comment by ljaniec on 2022-10-21:
Maybe is it a problem of ROS spinning? Can you add a few ros::spinOnce();
and ros::Duration(1).sleep();
in the code? You should also wait to send the first point to travel until every publisher/subscriber is set up correctly
Comment by gentle_yeti on 2022-10-21:
@ljaniec , yes it worked!!! I understand the issue now. The add_marker was launching the first marker and then removing it before the set up could start, I put up a ros::Duration(1).sleep(); and it worked perfectly, thank you so much for the answer.
Comment by gentle_yeti on 2022-10-21:
@ravijoshi I apologize for not sharing in a easy to view way, I am still learning a lot of things and I will definitely keep this in mind the next time
Comment by ljaniec on 2022-10-21:
@gentle_yeti
I will move this to the answer, so you can upvote and accept it, so it will be marked as solved in the queue, ok? I will also link related question with it answers.
You gave us the whole workspace with packages, it worked for me as MWE (but there was quite a lot of additional stuff, to be honest - the less code there is to analyze for others, the better).
Comment by gentle_yeti on 2022-10-21:
@ljaniec okay, sure I'll do so.
Okay, I understand, I'll keep it in mind to focus only on the required code and remove any additional stuff present, thanks for pointing that out, I didn't know about that.