我正在使用 turtlebot3 来测试不同的算法。我需要在同一环境/世界中的另一个 turtlebot3。我正在使用 rosservice 通过以下命令生成另一个 turtlebot3
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: ''"
我特将下面的论证作为
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'
当我输入时,终端出现以下错误
ERROR: service [/gazebo/spawn_urdf_model] responded with an error: b
您遇到的错误可能是由于
model_xml
字段的使用不当造成的。 model_xml
字段应包含实际的 URDF XML 字符串而不是文件路径。您可以使用以下命令将 URDF xacro 文件转换为 XML 字符串,然后生成新的 TurtleBot3 模型:
rosrun xacro xacro -o /tmp/turtlebot3_burger.urdf /home/mubashir/catkin_ws/src/turtlebot3/turtlebot3_description/urdf/turtlebot3_burger.urdf.xacro
export TURTLEBOT3_MODEL_XML=$(cat /tmp/turtlebot3_burger.urdf)
rosservice
变量的TURTLEBOT3_MODEL_XML
命令: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'"
记得在终端中一条一条地执行每条命令。运行这些命令后,您应该能够在同一环境中生成另一个 TurtleBot3 而不会遇到任何错误。