Simple simulation interface and template for setting up a hardware interface for ros_control. The idea is you take this as a starting point for creating your hardware interfaces, and it is needed because ros_control documentation is sparse. This boilerplate demonstrates:
This open source project was developed at PickNik Robotics. Need professional ROS development and consulting? Contact us at projects@picknik.ai for a free consultation.
Special thanks to the following maintainers of this repo:
See YouTube for a very modest video demo.
This package depends on gazebo_ros_demos for its rrbot_description
package, but you must add it to your catkin workspace by source:
git clone https://github.com/ros-simulation/gazebo_ros_demos.git
Then, either install this package from source so you can develop off of it, or install from debian:
sudo apt-get install ros-indigo-ros-control-boilerplate
This package is setup to run the "RRBot" two joint revolute-revolute robot demo. This "template package" is located in the ros_control_boilerplate as a subfolder that you can easily rename and reuse. To run its ros_control non-physics-based simulated hardware interface, run:
roslaunch ros_control_boilerplate rrbot_simulation.launch
To visualize its published /tf
coordinate transforms in Rviz run:
roslaunch ros_control_boilerplate rrbot_visualize.launch
To send a random, dummy trajectory to execute, run:
roslaunch ros_control_boilerplate rrbot_test_trajectory.launch
To test this as a simulation interface for your robot, you can quickly rename the subfolder package into the name of your robot using the following commands:
function findreplace() {
grep -lr -e "$1" * | xargs sed -i "s/$1/$2/g" ;
}
function findreplacefilename() {
find . -depth -name "*$1*" -exec bash -c 'for f; do base=${f##*/}; mv -- "$f" "${f%/*}/${base//'$1'/'$2'}"; done' _ {} +
}
findreplacefilename rrbot myrobot
findreplace rrbot myrobot
findreplace RRBot MyRobot
findreplace RRBOT MYROBOT
Then add the necessary code to communicate with your robot via USB/serial/ethernet/etc in the file myrobot_hw_interface.cpp
.
If you need your robot to startup at a particular position in simulation, or you would like to use this funcitonality to simulate your robot with MoveIt!, see the downstream package (it depends on this package) moveit_sim_controller
Write the commands from a trajectory controller to csv file
rosrun ros_control_boilerplate controller_to_csv SAVE_TO_FILE_PATH CONTROLLER_STATE_TOPIC TIME_TO_RECORD
Read from csv file and execute on robot
rosrun ros_control_boilerplate csv_to_controller READ_FROM_FILE_PATH CONTROLLER_STATE_TOPIC TIME_TO_RECORD
Joint-level teleop from a keyboard (TODO: remove had coded topic names)
rosrun ros_control_boilerplate keyboard_teleop
Please add features, make corrections, and address the limitations above, thanks!