Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory?
-
@yudonghou123 看一下gazebo启动指令,应该要有gazebo-ros-factory
-
@小鱼 在 Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory? 中说:
@yudonghou123 看一下gazebo启动指令,应该要有gazebo-ros-factory
您好,非常感谢您的回复,鱼总,这个gazebo启动指令不是只要在launch文件中有以下节点描述就可以是吗:
<node name="urdf_spawner" pkg="gazebo_ros" exec="spawn_entity.py" respawn="false" output="screen" args="-gazebo_namespace /gazebo -x $(var x) -y $(var y) -z $(var z) -R $(var roll) -P $(var pitch) -Y $(var yaw) -entity $(var namespace) -file $(var generated_urdf)"/>
或者您能说的详细一点吗,还是gazebo有时候会出现不识别urdf文件类型的问题,它启动的launch文件如下:
<launch> <arg name="debug" default="0"/> <arg name="x" default="0"/> <arg name="y" default="0"/> <arg name="z" default="-20"/> <arg name="roll" default="0.0"/> <arg name="pitch" default="0.0"/> <arg name="yaw" default="0.0"/> <arg name="mode" default="default"/> <arg name="namespace" default="rexrov"/> <arg name="use_ned_frame" default="false"/> <arg name="generated_urdf" default="$(find-pkg-share uuv_descriptions)/robots/generated/$(var namespace)/robot_description"/> <arg name="cmd" default= "$(exec-in-pkg xacro xacro) '$(find-pkg-share uuv_descriptions)/robots/rexrov_$(var mode).xacro' > $(find-pkg-share uuv_descriptions)/robots/generated/$(var namespace)/robot_description --inorder debug:=$(var debug) namespace:=$(var namespace) inertial_reference_frame:=world_ned"/> <arg name="cmdUnless" default="xacro '$(find-pkg-share uuv_descriptions)/robots/rexrov_$(var mode).xacro' > $(find-pkg-share uuv_descriptions)/robots/generated/$(var namespace)/robot_description debug:=$(var debug) namespace:=$(var namespace) inertial_reference_frame:=world"/> <arg name="use_sim_time" default="true"/> <group> <push-ros-namespace namespace="$(var namespace)"/> <group if="$(var use_ned_frame)"> <executable cmd="$(var cmd)" name="robot_description" output="screen" shell="true"> </executable> </group> <group unless="$(var use_ned_frame)"> <executable cmd="$(var cmdUnless)" cwd="$(find-pkg-prefix xacro)" name="robot_description" output="screen" shell="true"> </executable> </group> <!-- Run a python script to the send a service call to gazebo_ros to spawn a URDF robot --> <!-- <node name="urdf_spawner" pkg="uuv_descriptions" exec="spawn_model" respawn="false" output="screen" args="-urdf -x $(var x) -y $(var y) -z $(var z) -R $(var roll) -P $(var pitch) -Y $(var yaw) -model $(var namespace) -file /home/user2/auv_ws/install/uuv_descriptions/share/uuv_descriptions/robots/generated/rexrov/robot_description"/> --> <node name="urdf_spawner" pkg="gazebo_ros" exec="spawn_entity.py" respawn="false" output="screen" args="-gazebo_namespace /gazebo -x $(var x) -y $(var y) -z $(var z) -R $(var roll) -P $(var pitch) -Y $(var yaw) -entity $(var namespace) -file $(var generated_urdf)"/> <!-- A joint state publisher plugin already is started with the model, no need to use the default joint state publisher --> <!-- Publish robot model for ROS --> <node name="robot_state_publisher" pkg="robot_state_publisher" exec="robot_state_publisher" respawn="true" output="screen" args="$(var generated_urdf)"> <param name="use_sim_time" value="$(var use_sim_time)"/> <!-- <param name="robot_description" value="/$(var namespace)/robot_description" /> <param name="publish_frequency" value="5" /> --> </node> </group> <include file="$(find-pkg-share uuv_assistants)/launch/message_to_tf.launch"> <arg name="namespace" value="$(var namespace)"/> <arg name="world_frame" value="world"/> <arg name="child_frame_id" value="/$(var namespace)/base_link"/> </include> </launch>
-
侯总您好,您在下载完开源码之后是怎么操作的呢?我colcon build之后终端输出报错如下:
hao@hao-virtual-machine:~/ros2_ws$ colcon build --packages-up-to plankton Starting >>> plankton_utils Starting >>> uuv_gazebo_ros_plugins_msgs Starting >>> uuv_gazebo_plugins Starting >>> uuv_control_msgs Finished <<< plankton_utils [16.5s] Starting >>> uuv_assistants [Processing: uuv_assistants, uuv_control_msgs, uuv_gazebo_plugins, uuv_gazebo_ros_plugins_msgs] --- stderr: uuv_assistants In file included from /home/hao/ros2_ws/src/Plankton/uuv_assistants/src/message_to_tf.cpp:41: /opt/ros/humble/include/tf2_geometry_msgs/tf2_geometry_msgs/tf2_geometry_msgs.h:35:2: warning: #warning This header is obsolete, please include tf2_geometry_msgs/tf2_geometry_msgs.hpp instead [-Wcpp] 35 | #warning This header is obsolete, please include tf2_geometry_msgs/tf2_geometry_msgs.hpp instead | ^~~~~~~ /home/hao/ros2_ws/src/Plankton/uuv_assistants/src/message_to_tf.cpp:78:22: error: redefinition of ‘void tf2::fromMsg(const Point&, tf2::Vector3&)’ 78 | static inline void fromMsg(const geometry_msgs::msg::Point& msgIn, tf2::Vector3& out) | ^~~~~~~ In file included from /opt/ros/humble/include/tf2_geometry_msgs/tf2_geometry_msgs/tf2_geometry_msgs.h:37, from /home/hao/ros2_ws/src/Plankton/uuv_assistants/src/message_to_tf.cpp:41: /opt/ros/humble/include/tf2_geometry_msgs/tf2_geometry_msgs/tf2_geometry_msgs.hpp:241:6: note: ‘void tf2::fromMsg(const Point&, tf2::Vector3&)’ previously defined here 241 | void fromMsg(const geometry_msgs::msg::Point & in, tf2::Vector3 & out) | ^~~~~~~ gmake[2]: *** [CMakeFiles/uuv_message_to_tf.dir/build.make:76: CMakeFiles/uuv_message_to_tf.dir/src/message_to_tf.cpp.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/uuv_message_to_tf.dir/all] Error 2 gmake: *** [Makefile:146: all] Error 2 --- Failed <<< uuv_assistants [45.3s, exited with code 2] Aborted <<< uuv_gazebo_ros_plugins_msgs [1min 9s] Aborted <<< uuv_control_msgs [1min 48s] Aborted <<< uuv_gazebo_plugins [2min 22s] Summary: 1 package finished [2min 22s] 1 package failed: uuv_assistants 3 packages aborted: uuv_control_msgs uuv_gazebo_plugins uuv_gazebo_ros_plugins_msgs 2 packages had stderr output: uuv_assistants uuv_gazebo_plugins 17 packages not processed
不知道您是否有遇到或者正好懂得如何解决,感激不尽!
-
@2500718605 在 Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory? 中说:
侯总您好,您在下载完开源码之后是怎么操作的呢?我colcon build之后终端输出报错如下:
hao@hao-virtual-machine:~/ros2_ws$ colcon build --packages-up-to plankton Starting >>> plankton_utils Starting >>> uuv_gazebo_ros_plugins_msgs Starting >>> uuv_gazebo_plugins Starting >>> uuv_control_msgs Finished <<< plankton_utils [16.5s] Starting >>> uuv_assistants [Processing: uuv_assistants, uuv_control_msgs, uuv_gazebo_plugins, uuv_gazebo_ros_plugins_msgs] --- stderr: uuv_assistants In file included from /home/hao/ros2_ws/src/Plankton/uuv_assistants/src/message_to_tf.cpp:41: /opt/ros/humble/include/tf2_geometry_msgs/tf2_geometry_msgs/tf2_geometry_msgs.h:35:2: warning: #warning This header is obsolete, please include tf2_geometry_msgs/tf2_geometry_msgs.hpp instead [-Wcpp] 35 | #warning This header is obsolete, please include tf2_geometry_msgs/tf2_geometry_msgs.hpp instead | ^~~~~~~ /home/hao/ros2_ws/src/Plankton/uuv_assistants/src/message_to_tf.cpp:78:22: error: redefinition of ‘void tf2::fromMsg(const Point&, tf2::Vector3&)’ 78 | static inline void fromMsg(const geometry_msgs::msg::Point& msgIn, tf2::Vector3& out) | ^~~~~~~ In file included from /opt/ros/humble/include/tf2_geometry_msgs/tf2_geometry_msgs/tf2_geometry_msgs.h:37, from /home/hao/ros2_ws/src/Plankton/uuv_assistants/src/message_to_tf.cpp:41: /opt/ros/humble/include/tf2_geometry_msgs/tf2_geometry_msgs/tf2_geometry_msgs.hpp:241:6: note: ‘void tf2::fromMsg(const Point&, tf2::Vector3&)’ previously defined here 241 | void fromMsg(const geometry_msgs::msg::Point & in, tf2::Vector3 & out) | ^~~~~~~ gmake[2]: *** [CMakeFiles/uuv_message_to_tf.dir/build.make:76: CMakeFiles/uuv_message_to_tf.dir/src/message_to_tf.cpp.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:140: CMakeFiles/uuv_message_to_tf.dir/all] Error 2 gmake: *** [Makefile:146: all] Error 2 --- Failed <<< uuv_assistants [45.3s, exited with code 2] Aborted <<< uuv_gazebo_ros_plugins_msgs [1min 9s] Aborted <<< uuv_control_msgs [1min 48s] Aborted <<< uuv_gazebo_plugins [2min 22s] Summary: 1 package finished [2min 22s] 1 package failed: uuv_assistants 3 packages aborted: uuv_control_msgs uuv_gazebo_plugins uuv_gazebo_ros_plugins_msgs 2 packages had stderr output: uuv_assistants uuv_gazebo_plugins 17 packages not processed
不知道您是否有遇到或者正好懂得如何解决,感激不尽!
哦哦,你这个问题是重复定义,就是两个拥有相同变量的函数定义了两次,你把其中一个注释掉应该就OK
-
@yudonghou123 侯总我爱你!!!
不过我又遇到了下面的问题Starting >>> plankton_utils Starting >>> uuv_gazebo_ros_plugins_msgs Starting >>> uuv_gazebo_plugins Starting >>> uuv_control_msgs Finished <<< uuv_gazebo_plugins [1.73s] Starting >>> uuv_sensor_ros_plugins_msgs Finished <<< uuv_gazebo_ros_plugins_msgs [3.93s] Starting >>> uuv_world_ros_plugins_msgs Finished <<< uuv_sensor_ros_plugins_msgs [2.76s] Starting >>> uuv_world_plugins Finished <<< uuv_world_plugins [0.49s] Starting >>> uuv_gazebo_ros_plugins Finished <<< plankton_utils [5.77s] Starting >>> uuv_assistants Finished <<< uuv_control_msgs [7.19s] Starting >>> uuv_sensor_ros_plugins Finished <<< uuv_world_ros_plugins_msgs [4.63s] Starting >>> uuv_gazebo Finished <<< uuv_gazebo [0.48s] Starting >>> uuv_gazebo_worlds Finished <<< uuv_gazebo_worlds [0.65s] Starting >>> uuv_auv_control_allocator Finished <<< uuv_auv_control_allocator [4.49s] Starting >>> uuv_control_cascaded_pid Finished <<< uuv_control_cascaded_pid [1.80s] Starting >>> uuv_world_ros_plugins --- stderr: uuv_gazebo_ros_plugins In file included from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/gazebo_ros/node.hpp:144:19: error: ‘Executor’ was not declared in this scope; did you mean ‘rclcpp::Executor’? 144 | std::shared_ptr<Executor> executor_; | ^~~~~~~~ | rclcpp::Executor In file included from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /opt/ros/humble/include/gazebo_ros/node.hpp:18, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:65:7: note: ‘rclcpp::Executor’ declared here 65 | class Executor | ^~~~~~~~ In file included from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/gazebo_ros/node.hpp:144:27: error: template argument 1 is invalid 144 | std::shared_ptr<Executor> executor_; | ^ /opt/ros/humble/include/gazebo_ros/node.hpp:156:24: error: ‘Executor’ was not declared in this scope; did you mean ‘rclcpp::Executor’? 156 | static std::weak_ptr<Executor> static_executor_; | ^~~~~~~~ | rclcpp::Executor In file included from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /opt/ros/humble/include/gazebo_ros/node.hpp:18, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:65:7: note: ‘rclcpp::Executor’ declared here 65 | class Executor | ^~~~~~~~ In file included from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/gazebo_ros/node.hpp:156:32: error: template argument 1 is invalid 156 | static std::weak_ptr<Executor> static_executor_; | ^ /opt/ros/humble/include/gazebo_ros/node.hpp: In static member function ‘static gazebo_ros::Node::SharedPtr gazebo_ros::Node::CreateWithArgs(Args&& ...)’: /opt/ros/humble/include/gazebo_ros/node.hpp:182:38: error: request for member ‘lock’ in ‘gazebo_ros::Node::static_executor_’, which is of non-class type ‘int’ 182 | node->executor_ = static_executor_.lock(); | ^~~~ /opt/ros/humble/include/gazebo_ros/node.hpp:186:40: error: ‘Executor’ was not declared in this scope; did you mean ‘rclcpp::Executor’? 186 | node->executor_ = std::make_shared<Executor>(); | ^~~~~~~~ | rclcpp::Executor In file included from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /opt/ros/humble/include/gazebo_ros/node.hpp:18, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:65:7: note: ‘rclcpp::Executor’ declared here 65 | class Executor | ^~~~~~~~ In file included from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/gazebo_ros/node.hpp:225:18: error: base operand of ‘->’ is not a pointer 225 | node->executor_->add_node(node); | ^~ In file included from /opt/ros/humble/include/rclcpp/rclcpp/logging.hpp:24, from /opt/ros/humble/include/rclcpp/rclcpp/client.hpp:40, from /opt/ros/humble/include/rclcpp/rclcpp/callback_group.hpp:23, from /opt/ros/humble/include/rclcpp/rclcpp/any_executable.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategy.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/memory_strategies.hpp:18, from /opt/ros/humble/include/rclcpp/rclcpp/executor_options.hpp:20, from /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:37, from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /opt/ros/humble/include/gazebo_ros/node.hpp:18, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp: In member function ‘virtual void uuv_simulator_ros::FinROSPlugin::Load(gazebo::physics::ModelPtr, sdf::v9::ElementPtr)’: /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:122:69: error: cannot convert ‘std::__cxx11::basic_string<char>’ to ‘const char*’ 122 | CLCPP_INFO(myRosNode->get_logger(), "[FinROSPlugin] Namespace: " + std::string(myRosNode->get_namespace())); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | | | std::__cxx11::basic_string<char> In file included from /opt/ros/humble/include/rmw/rmw/types.h:28, from /opt/ros/humble/include/rcl/rcl/types.h:20, from /opt/ros/humble/include/rcl/rcl/log_level.h:22, from /opt/ros/humble/include/rcl/rcl/arguments.h:21, from /opt/ros/humble/include/rcl/rcl/context.h:28, from /opt/ros/humble/include/rcl/rcl/guard_condition.h:26, from /opt/ros/humble/include/rclcpp/rclcpp/executor.hpp:30, from /opt/ros/humble/include/rclcpp/rclcpp/executors/multi_threaded_executor.hpp:25, from /opt/ros/humble/include/rclcpp/rclcpp/executors.hpp:21, from /opt/ros/humble/include/rclcpp/rclcpp/rclcpp.hpp:155, from /opt/ros/humble/include/gazebo_ros/node.hpp:18, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/include/uuv_gazebo_ros_plugins/FinROSPlugin.h:31, from /home/hao/Plankton-master/uuv_gazebo_plugins/uuv_gazebo_ros_plugins/src/FinROSPlugin.cpp:22: /opt/ros/humble/include/rcutils/rcutils/logging.h:479:16: note: initializing argument 4 of ‘void rcutils_log(const rcutils_log_location_t*, int, const char*, const char*, ...)’ 479 | const char * format, | ~~~~~~~~~~~~~^~~~~~ gmake[2]: *** [CMakeFiles/uuv_fin_ros_plugin.dir/build.make:76: CMakeFiles/uuv_fin_ros_plugin.dir/src/FinROSPlugin.cpp.o] Error 1 gmake[1]: *** [CMakeFiles/Makefile2:149: CMakeFiles/uuv_fin_ros_plugin.dir/all] Error 2 gmake: *** [Makefile:146: all] Error 2 --- Failed <<< uuv_gazebo_ros_plugins [29.4s, exited with code 2] Aborted <<< uuv_assistants [31.5s] Aborted <<< uuv_sensor_ros_plugins [30.5s] Aborted <<< uuv_world_ros_plugins [21.9s] Summary: 11 packages finished [38.2s] 1 package failed: uuv_gazebo_ros_plugins 3 packages aborted: uuv_assistants uuv_sensor_ros_plugins uuv_world_ros_plugins 4 packages had stderr output: uuv_assistants uuv_gazebo_ros_plugins uuv_sensor_ros_plugins uuv_world_ros_plugins 7 packages not processed
个人感觉应该是路径问题?不知道该如何下手去改了
希望您不吝赐教! -
@2500718605 你这个可能是C++语言的问题,慢慢对这要求改就行,应该是有的符号没识别出来
-
@小鱼 在 Service %s/spawn_entity unavailable. Was Gazebo started with GazeboRosFactory? 中说:
@yudonghou123 看一下gazebo启动指令,应该要有gazebo-ros-factory
您好,我又换了一个模型,还是这样的问题,我以为是gazebo_ros的问题,于是运行humble/share/gazebo_ros中的文件发现能够运行,libgazebo_ros_factory.so也存在这样的依赖包,我是通过launch文件启动的
-
-
@yudonghou123 我觉得可能是gazebo启动的问题,自带的launch那个可能没有加gazebo_factory,你试试这样启动gazebo
start_gazebo_cmd = ExecuteProcess( cmd=['gazebo', '--verbose','-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so'], output='screen')
-
-
-
@小鱼 非常感激您的解答,原因是我陈列service时发现其对应的服务名称不对,程序调用的是前面加了一个命名空间,所以没有查找到对应的服务,我把多加的命名空间删除后,就可以了,已经改正过来了,模型也都能加载到gazebo环境中了,非常感激您,祝您身体健康
-
@yudonghou123
有详细步骤吗