Coder Social home page Coder Social logo

shaohangxu / quadruped_robcogen Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ori-drs/quadruped_robcogen

0.0 1.0 0.0 10.96 MB

RobCoGen code generator for any quadruped robot from the xacro description

License: BSD 3-Clause "New" or "Revised" License

CMake 71.36% Shell 28.64%

quadruped_robcogen's Introduction

quadruped_robcogen

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:

  1. the xacro file is converted into URDF via the standard xacro command
  2. the URDF is converted into a KINDSL file (the RobCoGen robot modelformat) with the urdf2kindsl command
  3. 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.

Dependencies

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 macro

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 the xacro command, one per line (see below)

Build the Code for Your Robot

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})

Xacro arguments

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)

...

Limitations

  • The transform files assumes the feet are named LF_FOOT, RF_FOOT, LH_FOOT and RH_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}

Credits

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.

License

This repository is released under the BSD License. See the LICENSE file for more details.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.