Reputation: 1821
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
.
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.
When I move the Led part from the hardware.xml
to a separate file (led.launch
) and launch robot.launch
first and then led.launch
everything works. When I am including led.launch
in robot.launch
(see below), it does not work.
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 appreciate any little hint pointing me to further debugging steps and eventually to the solution of my problem. Please let me know, if you need any further information.
My hardware.launch
:
<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>
My robot.launch
:
<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>
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>
Upvotes: 4
Views: 292
Reputation: 574
Based on launch files everything seems fine but what I think your mistake was when writing the nodes is that you initialized the node of 2 different code with same values that when 1 launches, stops the other one and so all will break (but not sure without seeing the errors).
You can try adding ros::init_options::AnonymousName
to your node.init and try again.
Upvotes: 1