控制代码无法控制gazebo里的小车
-
分别用roslaunch启动gazebo环境,用python运行控制代码,小车不动
查看rqt_graph,三个结点gazebo、gazebo_gui、RUN互相没有连接。分别查看结点和话题信息如下:(base) xxx@xxx-virtual-machine:~$ rosnode list /RUN /gazebo /gazebo_gui /rosout
(base) xxx@xxx-virtual-machine:~$ rosnode info RUN -------------------------------------------------------------------------------- Node [/RUN] Publications: * /cmd_vel [geometry_msgs/Twist] * /rosout [rosgraph_msgs/Log] Subscriptions: * /camera/rgb/image_raw [unknown type] * /clock [rosgraph_msgs/Clock] Services: * /RUN/get_loggers * /RUN/set_logger_level contacting node http://xxx-virtual-machine:39375/ ... Pid: 116647 Connections: * topic: /clock * to: /gazebo (http://xxx-virtual-machine:42671/) * direction: inbound * transport: TCPROS
(base) xxx@xxx-virtual-machine:~$ rosnode info gazebo -------------------------------------------------------------------------------- Node [/gazebo] Publications: * /clock [rosgraph_msgs/Clock] * /gazebo/link_states [gazebo_msgs/LinkStates] * /gazebo/model_states [gazebo_msgs/ModelStates] * /gazebo/parameter_descriptions [dynamic_reconfigure/ConfigDescription] * /gazebo/parameter_updates [dynamic_reconfigure/Config] * /rosout [rosgraph_msgs/Log] Subscriptions: * /clock [rosgraph_msgs/Clock] * /gazebo/set_link_state [unknown type] * /gazebo/set_model_state [unknown type] Services: * /gazebo/apply_body_wrench * /gazebo/apply_joint_effort * /gazebo/clear_body_wrenches * /gazebo/clear_joint_forces * /gazebo/delete_light * /gazebo/delete_model * /gazebo/get_joint_properties * /gazebo/get_light_properties * /gazebo/get_link_properties * /gazebo/get_link_state * /gazebo/get_loggers * /gazebo/get_model_properties * /gazebo/get_model_state * /gazebo/get_physics_properties * /gazebo/get_world_properties * /gazebo/pause_physics * /gazebo/reset_simulation * /gazebo/reset_world * /gazebo/set_joint_properties * /gazebo/set_light_properties * /gazebo/set_link_properties * /gazebo/set_link_state * /gazebo/set_logger_level * /gazebo/set_model_configuration * /gazebo/set_model_state * /gazebo/set_parameters * /gazebo/set_physics_properties * /gazebo/spawn_sdf_model * /gazebo/spawn_urdf_model * /gazebo/unpause_physics contacting node http://xxx-virtual-machine:42671/ ... Pid: 114613 Connections: * topic: /rosout * to: /rosout * direction: outbound (43625 - 127.0.0.1:46868) [22] * transport: TCPROS * topic: /clock * to: /gazebo * direction: outbound * transport: INTRAPROCESS * topic: /clock * to: /rosout * direction: outbound (43625 - 127.0.0.1:47148) [44] * transport: TCPROS * topic: /clock * to: /RUN * direction: outbound (43625 - 127.0.0.1:50992) [77] * transport: TCPROS * topic: /clock * to: /gazebo (http://xxx-virtual-machine:42671/) * direction: inbound * transport: INTRAPROCESS
(base) xxx@xxx-virtual-machine:~$ rostopic info cmd_vel Type: geometry_msgs/Twist Publishers: * /RUN (http://xxx-virtual-machine:39375/) Subscribers: None
可以看到两个结点并没有互相找到
试图通过在两个终端分别使用如下命令让两个结点访问11311端口,但并没有起效export ROS_HOSTNAME=localhost export ROS_MASTER_URI=http://localhost:11311
请问应该如何操作使得控制结点与gazebo结点连接起来呢?
(不知道为什么第一个代码块不显示包裹后的效果 )
-
通过以下命令安装ros-gazebo接口,实现ros-gazebo通信
sudo apt install ros-melodic-gazebo-ros-pkgs ros-melodic-gazebo-msgs ros-melodic-gazebo-plugins ros-melodic-gazebo-ros-control
参考资料
https://www.freesion.com/article/8223995772/
问题解决
-
-