Skip to content

Commit

Permalink
change node execution order in bringup launch file
Browse files Browse the repository at this point in the history
To fix issues in #30 launch the encoder scrip on the
microcontroller before launching the hardware interface
control loop. This will make sure to send actual tick values
from the encoders to the hardware interface before the control
loop is running.
  • Loading branch information
fjp committed Mar 31, 2021
1 parent 1232352 commit cb5ce1c
Showing 1 changed file with 24 additions and 19 deletions.
43 changes: 24 additions & 19 deletions diffbot_bringup/launch/minimal.launch
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
<launch>
<!-- Minimal launch file to bringup the robot hardware -->
<!-- This launch file will launch the package that communicates with the encoders
before running the ROS Controls hardware_interface control loop.
Launching the nodes in this order will make sure that the hardware_interface
receives meaningful tick values from the wheel encoders. -->

<!-- Including the following launch file from diffbot_base package will -->
<!-- Load the robot description onto the parameter server -->
<!-- Run the controller manager with DiffBot's hardware interface -->
<!-- Load the controller config onto the parameter server -->
<include file="$(find diffbot_base)/launch/diffbot.launch">
<!-- arg name="model" value="$(arg model)" /-->
</include>
<!-- Encoders -->
<!-- Run rosserial to connect with the Teensy 3.2 board connected to the motor encoders -->
<node name="rosserial_teensy" pkg="rosserial_python" type="serial_node.py" respawn="false"
output="screen" ns="diffbot" args="_port:=/dev/ttyACM0
_baud:=115200"/>

<!-- Motors -->
<!-- -->
<node name="motor_driver" pkg="grove_motor_driver" type="motor_driver.py" respawn="false"
output="screen" ns="diffbot" />

<!-- Including the following launch file from diffbot_base package will -->
<!-- Load the robot description onto the parameter server -->
<!-- Run the controller manager with DiffBot's hardware interface -->
<!-- Load the controller config onto the parameter server -->
<include file="$(find diffbot_base)/launch/diffbot.launch">
<!-- arg name="model" value="$(arg model)" /-->
</include>


<!-- Motors -->
<!-- -->
<node name="motor_driver" pkg="grove_motor_driver" type="motor_driver.py" respawn="false"
output="screen" ns="diffbot" />

<!-- Encoders -->
<!-- Run rosserial to connect with the Teensy 3.2 board connected to the motor encoders -->
<node name="rosserial_teensy" pkg="rosserial_python" type="serial_node.py" respawn="false"
output="screen" ns="diffbot" args="_port:=/dev/ttyACM0
_baud:=115200"/>
</launch>
</launch>

3 comments on commit cb5ce1c

@Russ76
Copy link
Contributor

@Russ76 Russ76 commented on cb5ce1c Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! I think I read of launch files, that the order doesn't matter so much, they are all basically started at once?
roslaunch launches local processes using popen and kills them using POSIX signals. roslaunch does not guarantee any particular order to the startup of nodes -- although this is a frequently requested feature, it is not one that has any particular meaning in the ROS architecture as there is no way to tell when a node is initialized.
http://wiki.ros.org/roslaunch/Architecture#Local_processes

@fjp
Copy link
Member Author

@fjp fjp commented on cb5ce1c Apr 5, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes that's a good point. At first I thought it would help to place the launch of the encoder and motor nodes before the hw interface node but as you noted this doesn't seem to matter. Although I noticed that the rosserial node started slightly earlier, it's not enough to fix the issue.

To take care of the launch order, I will try to use ros::Subscriber::getNumPublishers( ) inside the hardware interface. So before starting to loop (read(), update(), write()) inside the hardware interface, we can use its subscriber to wait for the encoder tick messages being published. So far I couldn't find a better approach for the launch order.

@pxalcantara
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In fact, you can't control the order that the nodes start in the launch file.

Please sign in to comment.