Ask Your Question
1

set initialpose for AMCL in code

asked 2014-06-08 02:03:25 -0500

dalishi gravatar image

Hi all

I followed the rviz source code 2D Pose Estimate which is the below function to set initialpose for AMCL in my own code.

void InitialPoseTool::onPoseSet(double x, double y, double theta)

It worked in publishing a single message to the topic initialpose. However this was not able to set the pose of the robot, because in rviz the pose of the robot never changed to the new one and in the console there also had not been showing any message like "[ROS_INFO] setting the robot pose to ..." as usual when we used the rviz 2D Pose Estimate tool.

But I finally made it work by using the latched ros publisher rather than the normal publisher

ros::Publisher advertise(const std::string& topic, uint32_t queue_size, bool latch = true)

The question I want to raise here is why the normal publisher without latch could work in rviz while I have to use the latched version to publish the message to set the pose?

Thanks all.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
4

answered 2014-06-08 02:24:08 -0500

ahendrix gravatar image

I suspect you're creating the publisher and then immediately publishing a single message to set the robot pose.

This is the usual race condition many new users run into, where subscribers often don't receive the first message on a topic.

The reason that this happens is that subscribers don't connect immediately when a publisher starts; they have to receive a callback that a new publisher exists and establish a TCP connection, before they can receive messages. This takes a few milliseconds, and usually mean that existing subscribers will miss the first few messages on a new topic.

The reason that a latched topic works for this, is that new subscribers to a latched topic will immediately receive the most recent message on a topic, regardless of when it was published.

edit flag offensive delete link more

Comments

Hi ahendrix, thanks for the explanation. Now I am getting more clear about this. Thanks.

dalishi gravatar image dalishi  ( 2014-06-08 23:56:17 -0500 )edit

Hi, are you able to visualize the pose estimate(you sent through code) in rviz?

Manav_Poddar gravatar image Manav_Poddar  ( 2018-07-03 22:11:36 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2014-06-08 02:03:25 -0500

Seen: 1,454 times

Last updated: Jun 08 '14