Strange behavior observed in sequential PID controllers

Issue #10 new
Vikrant Shah
created an issue

When I set up two controllers one depending on other as below. I observe that on one of my computers which is a bit resource limited, the 'pitch controller' doesn't publish the control_effort output /fins/elevator_cmd. When I run the two nodes one after another in separate launch file, the issues seems to go away.

I believe the cause might be a race situation between the two nodes when setting up the publishers & subscribers causing them to not register for some reason. Do you think this could be the cause?

 <node name="pitch_controller" pkg="pid" type="controller" output="screen" >
    <param name="node_name" value="pitch_pid" />
    <param name="Kp" value="25.0" />
    <param name="Ki" value="0.0" />
    <param name="Kd" value="0.00" />
    <param name="upper_limit" value="+0.5" />
    <param name="lower_limit" value="-0.5" />
    <param name="windup_limit" value="0.5" />
    <param name="max_loop_frequency"      value="1000.0" />
    <param name="min_loop_frequency"      value="2.0" />
    <param name="topic_from_controller"   value="fins/elevator_cmd" />      
    <param name="topic_from_plant"        value="pitch" />      
    <param name="setpoint_topic"          value="target_pitch" />      
    <param name="angle_error"             value="true" />      

 <node name="depth_controller" pkg="pid" type="controller" output="screen" >
    <param name="node_name" value="depth_pid" />
    <param name="Kp" value="0.1" />
    <param name="Ki" value="0.0" />
    <param name="Kd" value="0.00" />
    <param name="upper_limit" value="0.392699082" />
    <param name="lower_limit" value="-0.392699082" />
    <param name="windup_limit" value="0.15" />
    <param name="max_loop_frequency"      value="100.0" />
    <param name="min_loop_frequency"      value="2.0" />
    <param name="topic_from_controller"   value="target_pitch" />      
    <param name="topic_from_plant"        value="paro/depth" />      
    <param name="setpoint_topic"          value="target_depth" />      
    <param name="angle_error"             value="false" />      

      <node pkg="rostopic" type="rostopic" name="topic_0" args="pub /paro/depth std_msgs/Float64 'data: 0.0' -r 10" output="screen"/>

  <node pkg="rostopic" type="rostopic" name="topic_1" args="pub /target_depth std_msgs/Float64 'data: 2.0' -r 5" output="screen"/>

    <node pkg="rostopic" type="rostopic" name="topic_2" args="pub /pitch std_msgs/Float64 'data: 0.0' -r 20" output="screen"/>


Cheers, Vik

Comments (4)

  1. Vikrant Shah reporter

    So, the other thing I noticed is that when the PID node is not behaving correctly, when I ctrl-x out of it, it doesn't just stop cleanly. To close it, I have too ctrl-z and then kill it.

  2. Andy Zelenak repo owner

    Can you please checkout the new branch to see if it helps? It checks if the subscribers are initialized correctly and puts a ros::ok() in every while loop that might cause issues. Thanks Vik

    git checkout issue10

  3. Log in to comment