1

I am using turtlebot3 for testing different algorithms. I need another turtlebot3 in same environment/world. I am using rosservice to spawn another turtlebot3 by following command

rosservice call /gazebo/spawn_urdf_model "model_name: ''
model_xml: ''
robot_namespace: ''
initial_pose:
  position: {x: 0.5, y: 0.5, z: 0.0}
  orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
reference_frame: ''" 

I specifically the following argument as

model_name: 'my_turtlebot3'
model_xml:'/home/mubashir/catkin_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.urdf.xacro'`
robot_namespace: 'my_turtlebot3'
reference_frame: 'odom'

when I entered I got the following error in terminal ERROR: service [/gazebo/spawn_urdf_model] responded with an error: b

Mubahsir
  • 45
  • 9

1 Answers1

0

The error you're encountering is likely due to the incorrect usage of the model_xml field. The model_xml field should contain the actual URDF XML string rather than the file path. You can use the following command to convert your URDF xacro file to an XML string and then spawn the new TurtleBot3 model:

  1. First, convert the xacro file to a URDF file:
rosrun xacro xacro -o /tmp/turtlebot3_burger.urdf /home/mubashir/catkin_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.urdf.xacro
  1. Load the URDF file content into a variable:
export TURTLEBOT3_MODEL_XML=$(cat /tmp/turtlebot3_burger.urdf)
  1. Finally, use the rosservice command with the new TURTLEBOT3_MODEL_XML variable:
rosservice call /gazebo/spawn_urdf_model "model_name: 'my_turtlebot3'
model_xml: '$TURTLEBOT3_MODEL_XML'
robot_namespace: 'my_turtlebot3'
initial_pose:
  position: {x: 0.5, y: 0.5, z: 0.0}
  orientation: {x: 0.0, y: 0.0, z: 0.0, w: 0.0}
reference_frame: 'odom'"

Remember to execute each command one by one in the terminal. After running these commands, you should be able to spawn another TurtleBot3 in the same environment without encountering any errors.

Dr No
  • 118
  • 5
  • This answer looks like it was generated by an AI (like ChatGPT), not by an actual human being. You should be aware that [posting AI-generated output is officially **BANNED** on Stack Overflow](https://meta.stackoverflow.com/q/421831). If this answer was indeed generated by an AI, then I strongly suggest you delete it before you get yourself into even bigger trouble: **WE TAKE PLAGIARISM SERIOUSLY HERE.** Please read: [Why posting GPT and ChatGPT generated answers is not currently acceptable](https://stackoverflow.com/help/gpt-policy). – tchrist Jul 04 '23 at 14:49