This package allows to generate the C++ RobCoGen code for any quadruped robot with 12 active DoF. The code includes forward/inverse kinematics and dynamics.
Under the hood the code is generated in three steps:
- the xacro file is converted into URDF via the standard
xacro
command - the URDF is converted into a KINDSL file (the RobCoGen robot modelformat) with the
urdf2kindsl
command - the
${ROBOT_NAME}.kindsl
model and the transforms file${ROBOT_NAME}.dtdsl
(where${ROBOT_NAME}
is the name of your robot) are passed to the RobCoGen executable to make the CPPs
All the above programs are either copied locally into this repo or available from ROS.
This repository contains a slightly modified copy (to bypass the interactive menu) of the RobCoGen executable (version 5.0.1), which is written in Java. The following dependencies are therefore required to run the program correctly:
- Java JRE
- ANT
- Ivy
- Maxima
- gcc
On Ubuntu, these can be installed as follows:
sudo apt install openjdk-8-jre ant ivy maxima gcc
NOTE: Ivy has a faulty installation. If you experience problems, you can fix with a symlink:
sudo ln -s /usr/share/java/ivy.jar /usr/share/ant/lib/ivy.jar
The generated code also depends on the Rigid Body Dynamics (RBD) interfaces available as part of the pronto project. This is a catkinized copy of the original code here.
The robcogen.cmake file defines the macro to be used within your custom CMakeLists.txt
to generate the code for your robot. It takes two arguments:
ROBOT_NAME
is the name of your robot, e.g.,fido
ROBOT_DESCRIPTION_PKG_NAME
(optional) is the name of the package where to fetch the xacro description of the robot. Default:${ROBOT_NAME}_description
ROBOT_XACRO_NAME
(optional) name of the xacro file to be parsed, without extension. Default:${ROBOT_NAME}
XACRO_ARGS_FILE
(optional) absolute path of a file containing the arguments to be passed to thexacro
command, one per line (see below)
To generate the code for your robot, create a catkin package that depends on
quadruped_robcogen
and use the provided the robcogen
cmake macro to build your code.
You can easily do this by running the provided script generate_catkin_pkg.sh
, which takes the same arguments as the cmake macro described above.
For example, the following command
rosrun quadruped_robcogen generate_catkin_pkg.sh fido
Would produce the a CMakeLists.txt
for a robot called fido
:
cmake_minimum_required(VERSION 3.0.2)
project(fido_robcogen)
add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS pronto_quadruped_commons
quadruped_robcogen
fido_description)
set(LIB_NAME ${PROJECT_NAME})
find_package(Eigen3)
catkin_package(INCLUDE_DIRS include
LIBRARIES fido_robcogen
CATKIN_DEPENDS pronto_quadruped_commons
quadruped_robcogen
fido_description)
include_directories(include
${catkin_INCLUDE_DIRS})
include_directories(./include)
include_directories(./include/${PROJECT_NAME})
include(${quadruped_robcogen_SOURCE_PREFIX}/cmake/robcogen.cmake)
# call the macro to generate the C++ code
robcogen(fido fido_description fido)
install(TARGETS ${LIB_NAME}
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_GLOBAL_BIN_DESTINATION})
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})
If your xacro file has arguments, you can pass them to the robcogen
cmake macro as a file located in the config
folder of your robot package.
The file has to have one argument per line.
For example, the fido.urdf.xacro
from the fido_description
package might have the two arguments simulation
and sensors
to decide whether to include links/joints specific for simulation and perception, repsectively. These can be set in the fido_robcogen/config/xacro_args.txt
file as follows:
simulation:=false
sensors:=true
Then, the filename would be passed as a fourth argument to the robcogen
macro:
cmake_minimum_required(VERSION 3.10.2)
project(fido_robcogen)
...
robcogen(fido fido_description fido ${CMAKE_CURRENT_SOURCE_DIR}/config/xacro_args.txt)
...
- The transform files assumes the feet are named
LF_FOOT
,RF_FOOT
,LH_FOOT
andRH_FOOT
. If you have different names for your end effectors, you have to manually change them here. - The robot is assumed to have an IMU with a link called
imu_link
acting as coordinate frame for its measurementas.
Again, you can change the name in the template here. - The xacro file path is assumed to be
${ROBOT_DESCRIPTION_PKG_NAME}/urdf/${ROBOT_XACRO_NAME}.xacro.urdf
- links and joints names inside the xacro file CANNOT start with a number
- The name of the robot defined the xacro file has to be
${ROBOT_NAME}
Main author: Marco Camurri
All the material under the external
folder (i.e., the RobCoGen
and urdf2kindsl
programs) have been originally developed by Marco Frigerio.
This repository is released under the BSD License. See the LICENSE file for more details.