我有一个由不同的Nodelet和控制器组成的自定义机器人,这些Nodelet和控制器按子程序包组织:
.
├── project
│ ├── launch
├── project_description
│ └── urdf
├── project_hardware
│ ├── config
│ ├── launch
├── project_logic
│ ├── launch
├── project_networking
└── project_vision
我按照常规的ROS方法(即自定义界面,句柄,控制器,消息)实现了自定义
LedController
来控制硬件上的某些LED。当我启动位于
hardware.launch
中的project_hardware
时,控制器工作正常(即通过相应的主题将Led设置为给定值)。但是,当我使用全局启动文件
LedController
启动所有内容时,controller_manager
死亡(并杀死robot.launch
进而杀死所有其他控制器),该文件位于另一个名为仅。当我将Led部分从
project
移到一个单独的文件(hardware.xml
)并先启动led.launch
,然后启动robot.launch
时,一切正常。当我在led.launch
中包含led.launch
时(见下文),它不起作用。由于工作与不工作之间的区别仅是包含
robot.launch
或通过led.launch
手动启动它的问题,所以我没有调试想法。我很欣赏任何提示,指出我需要进一步的调试步骤并最终解决问题。如果您需要任何进一步的信息,请告诉我。我的
roslaunch
:<launch>
<arg name="nodelet_manager" default="nodelet_manager" />
<node name="$(arg nodelet_manager)" pkg="nodelet" type="nodelet" args="manager" />
<param name="robot_description" command="$(find xacro)/xacro.py '$(find project_description)/urdf/ccs_robot.xacro'" />
<include file="$(find project_hardware)/launch/hardware.xml">
<arg name="nodelet_manager" value="$(arg nodelet_manager)" />
</include>
</launch>
我的
hardware.launch
与hardware.xml
:<launch>
<arg name="nodelet_manager" />
<rosparam file="$(find project_hardware)/config/drive_controller.yaml" />
<node name="drive_controller_spawner" pkg="controller_manager" type="spawner" args="drive_controller --shutdown-timeout 2" />
<node name="driver" pkg="nodelet" type="nodelet" args="load project/RobotNodelet $(arg nodelet_manager)" >
<param name="rate" value="100" />
<param name="ros_hw_velocity_conversion_factor" value="5.615" />
<param name="ros_hw_led_max_value" value="64" />
</node>
<rosparam file="$(find project_hardware)/config/distance_sensor_controller.yaml" />
<node name="distance_sensor_controller_spawner" pkg="controller_manager" type="spawner" args="distance_sensor_controller --shutdown-timeout 2" />
<rosparam file="$(find project_hardware)/config/led_controller.yaml" />
<node name="led_controller_spawner" pkg="controller_manager" type="spawner" args="led_controller --shutdown-timeout 2" />
</launch>
我的
LedController
:<launch>
<arg name="nodelet_manager" default="nodelet_manager" />
<node name="$(arg nodelet_manager)" pkg="nodelet" type="nodelet" args="manager" />
<param name="robot_description" command="$(find xacro)/xacro.py '$(find project_description)/urdf/ccs_robot.xacro'" />
<node name="robot_state_publisher" pkg="robot_state_publisher" type="robot_state_publisher"/>
<include file="$(find project_vision)/launch/feature_extraction.xml">
<arg name="nodelet_manager" value="$(arg nodelet_manager)" />
</include>
<include file="$(find project_logic)/launch/demo_app.xml" />
<include file="$(find project_logic)/launch/logic.xml">
<arg name="nodelet_manager" value="$(arg nodelet_manager)" />
</include>
<include file="$(find project_hardware)/launch/hardware.xml">
<arg name="nodelet_manager" value="$(arg nodelet_manager)" />
</include>
<!--<include file="$(find project_hardware)/launch/led.launch" />-->
<include file="$(find project_networking)/launch/monitoring.launch" />
</launch>
我的
robot.launch
没有hardware.xml
:<launch>
<arg name="nodelet_manager" />
<rosparam file="$(find project_hardware)/config/drive_controller.yaml" />
<node name="drive_controller_spawner" pkg="controller_manager" type="spawner" args="drive_controller --shutdown-timeout 2" />
<node name="driver" pkg="nodelet" type="nodelet" args="load project/RobotNodelet $(arg nodelet_manager)" >
<param name="rate" value="100" />
<param name="ros_hw_led_max_value" value="64" />
</node>
<rosparam file="$(find project_hardware)/config/distance_sensor_controller.yaml" />
<node name="distance_sensor_controller_spawner" pkg="controller_manager" type="spawner" args="distance_sensor_controller --shutdown-timeout 2" />
</launch>
我的
LedController
包含Led部分从led.launch
移出:<launch>
<rosparam file="$(find project_hardware)/config/led_controller.yaml" />
<node name="led_controller_spawner" pkg="controller_manager" type="spawner" args="led_controller --shutdown-timeout 2" />
</launch>
最佳答案
基于启动文件,一切似乎都很好,但是我认为您写节点时的错误是,您使用相同的值初始化了2个不同代码的节点,当它们启动时,它们停止了另一个,因此所有代码都会中断(但不确定看到错误)。
您可以尝试将ros::init_options::AnonymousName
添加到您的node.init中,然后重试。
关于controller - 在全局启动文件中启动时,自定义 Controller 消失,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/44373075/