ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Why is my marker getting displayed at location 2 but not location 1?

asked 2022-10-19 11:26:33 -0500

gentle_yeti gravatar image

updated 2022-10-30 09:39:48 -0500

lucasw gravatar image

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.

edit retag flag offensive close merge delete

Comments

1

I suggest creating and sharing a minimal reproducible example.

ravijoshi gravatar image ravijoshi  ( 2022-10-21 02:45:58 -0500 )edit
1

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

ljaniec gravatar image ljaniec  ( 2022-10-21 04:51:00 -0500 )edit

@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.

gentle_yeti gravatar image gentle_yeti  ( 2022-10-21 11:00:58 -0500 )edit

@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

gentle_yeti gravatar image gentle_yeti  ( 2022-10-21 11:03:23 -0500 )edit
1

@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).

ljaniec gravatar image ljaniec  ( 2022-10-21 11:59:31 -0500 )edit

@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.

gentle_yeti gravatar image gentle_yeti  ( 2022-10-21 13:51:09 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2022-10-21 12:03:26 -0500

ljaniec gravatar image

As in the comment:

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.

It is connected with e.g. this question "What is first ? Publisher or Subscriber?"

Which among the following nodes should be started first? Publisher or Subscriber.

and its answers:

  • "In general it should not matter. You can start publishers and subscribers at any time. However, note that ROS is expecting messages as a constant message stream, e.g., like from a sensor. They are not buffered in some central instance. This explains why it misses receiving initial messages. It just wasn't there to listen."

  • "This is a common topic in IPC (interprocess communication). In general, the publish/subscribe model can be thought of like a radio broadcast where there is some time between initialization of a node and when it is functional. If you start the publisher first, then there will be a brief period of time when the node is broadcasting messages and the subscriber is not able to listen yet as it hasn't initialized fully. This can technically still happen with the subscriber starting first as the initialization time is not the same for publisher and subscribers (depends on implementation)."

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2022-10-19 11:26:33 -0500

Seen: 51 times

Last updated: Oct 21 '22