Robotics StackExchange | Archived questions

Custom controller dies when launched in global launch file

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 2" />
</launch>

Since the difference between working and not working is only a matter of including led.launch or starting it by hand via roslaunch, I am out of debugging ideas. I would appreciate any little hint pointing me to further debugging and eventually to the solution of my problem. Please let me know, if you need any further information.

Asked by Salir on 2017-06-07 07:19:44 UTC

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?

Asked by huanxiner on 2017-06-07 12:42:43 UTC

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.

Asked by Salir on 2017-06-07 13:47:10 UTC

Answers