Custom controller dies when launched in global launch file

asked 2017-06-07 07:19:44 -0600

Salir gravatar image

I have a custom robot consisting of different nodelets and controllers which are organized in sub-packages:

.
├── project
│   ├── launch
├── project_description
│   └── urdf
├── project_hardware
│   ├── config
│   ├── launch
├── project_logic
│   ├── launch
├── project_networking
└── project_vision

I implemented a custom LedController to control some Leds on my hardware following the usual ROS approach (i.e. custom interface, handle, controller, message).

The controller works fine (i.e. setting the Leds to given values via the corresponding topic), when I am launching my hardware.launch which is located in project_hardware:

<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>

My hardware.xml with the LedController:

<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>

However, the LedController dies (and also kills the controller_manager which in turn kills all my other controllers), when I am launching everything with my global launch file robot.launch which is located in a different sub-package called project only:

<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>

When I move the Led part from the hardware.xml to a seperate file (led.launch) and launch robot.launch first and then led.launch everything works. When I am including led.launch in robot.launch (see above), it does not work.

My hardware.xml without the LedController:

<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>

My led.launch containing the Led part moved from the hardware.xml:

<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 ...
(more)
edit retag flag offensive close merge delete

Comments

Could it be the ordering of the launch files in the robot.launch? What happens when you move led.launch to the end of robot.launch?

huanxiner gravatar imagehuanxiner ( 2017-06-07 12:42:43 -0600 )edit

Unfortunately, this did not solve the issue. According to the wiki the order of nodes in the launch file is not considered in ROS. I tested including the LedController in every possbile way and combination but the only case where it worked was the seperate roslaunch.

Salir gravatar imageSalir ( 2017-06-07 13:47:10 -0600 )edit