Coder Social home page Coder Social logo

gstavrinos / calc-inertia Goto Github PK

View Code? Open in Web Editor NEW
36.0 2.0 5.0 18 KB

Based on a provided URDF (or xacro), it reads all geometries that have a mass inertial tag, and prints a URDF-ready inertia matrix.

License: The Unlicense

Python 100.00%
inertia mesh ros ros2 urdf xacro xacro-urdf

calc-inertia's Introduction

calc_inertia_for_urdf.py

Based on a provided URDF (or xacro), it reads all geometries that have a mass inertial tag, and prints a URDF-ready inertia matrix.

Dependencies

  • xacro (pip install xacro)
  • numpy-stl (pip install numpy-stl)
  • pycollada (pip install pycollada)
  • urdf_paser_py (pip install urdf-parser-py)

Install with pip install -r requirements.txt

Command line params

  • 1: URDF file

Features added in release 2.1

  • Support for Collada (.dae) mesh files (in addition to STL)

Features added in release 2.0

  • Support for ROS1 AND ROS2. This functionality basically involves looking for mesh files in package:// tags. (If your urdf/xacro only includes file:// tags, there is nothing ROS-related to worry about)
  • Support for ALL kind of geometries (mesh, box, sphere, cylinder)
  • Xacro integration for files that use arguments or parameters in fields of interest
  • Support for links that have inertia but not a visual tag (collisions only)

Example

python calc_inertia_for_urdf.py /home/gstavrinos/urdfs/model.urdf

Output

 Link name: chassis_link_00
 Mass: 48.0
 Scale: [0.015, 0.015, 0.015]
 Mesh: file:///home/gstavrinos/ros2_ws/install/kart_description/share/kart_description/meshes/kart_chassis.stl
---
Calculating inertia...
---

<inertia  ixx="107.96846534714074" ixy="0" ixz="0" iyy="279.5263367708269" iyz="0" izz="346.94143021711494" />

 Link name: steering_wheel_link_00
 Mass: 7.0
 Scale: [0.015, 0.015, 0.015]
 Mesh: file:///home/gstavrinos/ros2_ws/install/kart_description/share/kart_description/meshes/kart_steering_wheel.stl
---
Calculating inertia...
---

<inertia  ixx="1.7008840358588881" ixy="0" ixz="0" iyy="2.939219711456205" iyz="0" izz="3.1101995734940084" />
.
.
.


calc_inertia.py

⚠️Currently deprecated⚠️

With an object's STL file and mass, calculate its inertia, based on its bounding box, in mass * dimension * scale. The output is URDF-ready.

Dependencies (Compatible with both Python2 and Python3)

  • numpy-stl (sudo pip install numpy-stl)

Command line params

  • 1: STL file
  • 2: Mass (in kg)
  • 3: Scale (in case you are scaling your model before use)(= 0.000001 if stl is in mm)

Example

python calc_inertia.py "/home/gstavrinos/meshes/model.stl" 0.025 1

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.