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

Spawning Multiple Turtles in a python

asked 2019-05-28 16:56:55 -0500

jeffersonkim97 gravatar image

Hello,

I am trying to use multiple turtles in turtlesim to move from one waypoint to another. What I am trying to do is having multiple turtles with different waypoints and turtles would talk to each other to avoid multiple turtles choosing identical waypoints.

So far I was able to spawn different turtles in terminal using ROSSERVICE in turtorial, and I am aware that we can use roslaunch file to spawn multiple turtles, but I am not sure these methods can serve my purpose. I think it would be best to spawn multiple turtles on a python script to make them communicate each other, but I am not sure if there is a tutorial already exist for this case.

Any advice?

edit retag flag offensive close merge delete

Comments

Can you please update your question with a link to the tutorial that you're referring to?

jayess gravatar image jayess  ( 2019-06-08 13:51:56 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-06-08 05:13:52 -0500

dasanche gravatar image

updated 2019-06-08 13:50:35 -0500

jayess gravatar image

What do you mean you spawned different turtles using ROSSERVICE, did you use something like this?

rosservice call /spawn 2 7 0.2 "another_turtle"

In that case, every time you spawn a new turtle, you will be able to move it independently publishing command velocities under the namespace of the new turtles, in the example above it would be:

/another_turtle/cmd_vel

Therefore, you can move it by:

rostopic pub /another_turtle/cmd_vel geometry_msgs/Twist "linear:
  x: 2.0
  y: 0.0
  z: 0.0
angular:
  x: 0.0
  y: 0.0
  z: 0.0"

Then, if you want to move and control all the turtles to different waypoints, you need to write a program which:

  • Checks where the turtles are.
  • Compute, for each turtle, a way to get to their goal.
  • Follow their paths and coordinate their movements if necessary (your planner may be able to do so already)
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2019-05-28 16:56:55 -0500

Seen: 3,897 times

Last updated: Jun 08 '19