How to call a Rosservice at startup?

asked 2021-05-07 07:37:13 -0500

For my project I want to actively localize a turtlebot in a given environment, however the initial pose of the turtlebot is not known. This suggests that I should make use of the rosservice /global_localization, calling this should give me a uniform random distribution of AMCL particles.

However I can't seem to find a proper way to initialize my AMCL node using the /global localization service. I've tried the process from the following answer: But this does not work for me. Moreover I've also tried to call the global localization as a node called 'rosservice' like also suggested in one of the answers from the url above.

So how do I call this global localization rosservice properly at startup, so that my AMCL initializes with a global localization distribution?

It goes without saying that I am new to ROS and that I am quite the noob.

edit retag flag offensive close merge delete



But this does not work for me.

thing is, we cannot help you with such a meager description of what is going on.

If something doesn't appear to work, describe what you observe. It's likely there are errors messages or warnings printed on the (roslaunch) console. If that's the case, copy paste them here into your post (do not post screenshots of terminals).

If you're not seeing anything, make sure to add --screen to the roslaunch command line you're using. That will force all nodes to print to the screen (instead of only to a log).

gvdhoorn gravatar image gvdhoorn  ( 2021-05-08 06:08:33 -0500 )edit

Thanks for your reply. This is my first question on the forum, so I will try to improve my formulation of my question in the future, thanks for the feedback!

Luckily, I already managed to find and fix the issue. What I think happened was that the \global_localization service was called too soon, likely to the extent that it was called before AMCL runs. So the AMCL node would not initialze with a uniform random distribution, but rather with a distribution around an initial pose. I managed to fix it, by writing a simple service client like in the ros tutorial. I use this as a seperate node and basically what it does is waiting for 1 second before actually calling the \global_localization service. By doing so I am able to initialize my AMCL with global localization instead of an initial pose.

Jurjen Kuijstermans gravatar image Jurjen Kuijstermans  ( 2021-05-08 06:22:13 -0500 )edit

Luckily, I already managed to find and fix the issue

Good to hear.

Please post that as an answer and answer your question.

gvdhoorn gravatar image gvdhoorn  ( 2021-05-08 06:24:23 -0500 )edit