0
$\begingroup$

Rosanswers logo

Hello!

I am currently working on a project where I navigate a TurtleBot3 to several positions in a room. The TB3 navigation is triggered by publishing messages to a specific topic (/tb3_hsc/command). These messages are published through a seperate Python script. By seperate I mean that it is not a ROS package, but a .py file that I run from a terminal.

When a position has been reached, a message appears on /rosout/msg that says "Goal reached". What I want to do, is capture the output from /rosout/msg from the moment I send the navigation command (so any messages published to that topic from before the navigation command, should not be included). Then, once the output contains the string "Goal reached", I want the Python script to trigger a new command.

Does anyone have an idea how I can do this?

Thanks in advance!


Originally posted by anonymous55390 on ROS Answers with karma: 18 on 2020-06-03

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

This is a bit of an XY problem situation. You do not need to parse /rosout to get the status of the current goal. You can ask the move base instance what the status of the goal is. Move base API and actionlib python tutorial should get you most of the way to where you want to get.

Of course you you could (but should not) just subscribe to the /rosout topic and filter the messages by the /rosout/name and look for "goal reached" in /rosout/msg. If you do for what ever reason want to proceed with parsing the output use /rosout_agg instead of plain /rosout. /rosout_agg is published by the rosout node, subscribing directly to /rosout would connect your node to all of the nodes that publish to /rosout, which would be basically all of the running nodes.

If having it in "separate Python script" is somehow preventing you from doing this then you would need to elaborate on what you mean by "separate Python script" and why you want to use said script instead of having it in a ros package.


Originally posted by Reamees with karma: 591 on 2020-06-03

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by anonymous55390 on 2020-06-03:
Thanks for your fast and useful response! I will definitely use the move base API instead of /rosout, that is indeed a better option. This will certainly help me achieve my goal :)

I'm not sure if my Python script has to be seperate (by which I mean that it is not a ROS package, but it is a .py file in my home folder that I execute through a terminal), but that's the way I set it up initially. But with your solution, the Python script can remain seperate, so thanks a lot! :)

Comment by anonymous55390 on 2020-06-03:
Just as an update:

I've been able to use rospy and MoveBaseActionResult from move_base_msgs.msg to "read" whether the robot has reached its destination. This all works within my Python script now. So thanks again for your information!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.