Ask Your Question
0

Is it possible to control movement of turtlesim by string msgs?

asked 2020-11-11 20:37:31 -0500

zaid gravatar image

I am working on a project and i want to control movement of turtlesim by publishing to a topic with strings. For example, if i send "play" the turtle start moving while with publishing "STOP", it will stop. Beside publishing the coordinates, is it possible to control turtle with strings. And if such is possible with turtlebot, it would be great. Thank you

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2020-11-13 06:38:57 -0500

shiraz_baig gravatar image

Perhaps you can even do with only one node. In the same node, create a subscriber and a publisher. The subscriber, in its call back listens to string mesgs play/stop. Then, in a switch or if-else stmt, it publishes twist messages via publisher as explained above by Gerry.

edit flag offensive delete link more
0

answered 2020-11-13 01:18:50 -0500

Gerry gravatar image

I guess you can publish string "play"/"stop" via message std_msgs/String. Then you create another node listening to this topic. Based on the string received, this node publish topic 'cmd_vel' with message geometry_msgs/Twist. If the string is "play", then you set some linear/angular velocity in Twist message. This should be able to make it move. On the other side, if the string is "stop", just set linear/angular velocity as 0.

Hope this helps, Gerry

edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower

Stats

Asked: 2020-11-11 20:37:31 -0500

Seen: 39 times

Last updated: Nov 13 '20