How to Debug Controlit! Using gdb

How to Execute controlit_exec in gdb

Execute the following:

$ ROS_NAMESPACE=[controller namespace] gdb -ex run --args `rospack find controlit_exec`/../../../devel/lib/controlit_exec/controlit_exec

How to Execute Gazebo in gdb

Open the "gazebo.launch" file for the demo want to debug. Comment out the line that starts Gazebo. For example, here is how the gazebo.launch file should look for stickbot_lowerleg_3dof_controlit:

<?xml version="1.0" ?>
<launch>
    <!-- Enable simulation time -->
    <param name="/use_sim_time" type="bool" value="true"/>

    <!-- Load the robot description parameter-->
    <param name="robot_description"
        command="$(find xacro)/xacro.py '$(find stickbot_lowerleg_3dof)/models/stickbot_lowerleg_3dof/xacro/stickbot_lowerleg_3dof.xacro'" />

    <!-- Start gazebo with robot. -->
    <!-- <node args="$(find stickbot_lowerleg_3dof_controlit)/worlds/stickbot_lowerleg_3dof_controlit.world"
        name="gazebo" pkg="hcrl_simulator" type="run_gazebo" ns="stickbot_lowerleg_3dof_controller"/> -->

    <!-- Start a shared memory manager. -->
    <node name="SMManager" pkg="shared_memory_interface" type="shared_memory_manager" 
        output="screen" ns="/" respawn="false"/>

</launch>

Start the simulation:

$ roscore
$ roslaunch [demo package] gazebo.launch
$ gdb -ex run --args gazebo -s libgazebo_ros_api_plugin.so --verbose -u /[path to demo package]/worlds/[demo name].world

Next you can load the ControlIt! parameters and start the ControlIt! controller.