Skip to main content

Gazebo SDF utils - write smaller and simpler xacro and get richer and complex SDF files

Project description

SDFUtils

Gazebo SDF utils. Write smaller and simpler xacro and get richer and complex SDF files.

basic usage:

python3 xacro2sdf.xacro2sdf input_xacro_file output_sdf_file

XACRO

  • properties
  • macro
  • include
  • pure python

properties

  • declare variable to use by other sdf section
source sdf with xacro tags
<sdf xmlns:xacro="http://xacro">
    <xacro:property name="width" value=".2" />
    <xacro:property name="bodylen" value=".6" />
    <xacro:property name="x" value="1" />
    <xacro:property name="y" value="2" />
    <xacro:property name="z" value="3" />
    <link name="base_link">
        <pose>${x} ${y} ${z} 0 0 0</pose>
        <visual>
            <geometry>
                <cylinder radius="${2*width}" length="${bodylen}" />
            </geometry>
        </visual>
    </link>
</sdf>
output sdf
<sdf >
    <link name="base_link">
        <pose>1.0 2.0 3.0 0 0 0</pose>
        <visual>
            <geometry>
                <cylinder radius="0.4" length="0.6"/>
            </geometry>
        </visual>
    </link>
</sdf>

include

include other xacro files to use

  • file:// : load files relative to sdf/xacro file
  • package:// : load files from helper folder under script source folder
<xacro:include uri="file://data.xacro" />
<xacro:include uri="package://common.xacro" />
<xacro:include uri="package://color.xacro" />
  • data.xacro: custom file hold data properties for example
  • common.xacro: common macro's like inertia and basic geometry
  • color.xacro: color and texture macro's

pure python

  • use python inside your models, ident the same as in python (starting from column 0)!
  • store your needed variables in "return_values" dictionary and use them later in the model by the given keys.
    <xacro:python>
    <![CDATA[
import numpy as np 
def foo(): 
    if 2 > 5: 
        return 5,4,3,2,1
    global np
    b = np.array([0,1])
    x = 3433
    y = 324
    z = 3
    m = 1
    return x,y,z,m,b
temp = foo()
return_values = {'x': temp[0], 'y': temp[1], 'z': temp[2], 'm': temp[3], 'b': temp[4]}
]]>
    </xacro:python> 

common

macros

  • inertia_box
  • inertia_sphere
  • inertia_cylinder
  • geometry_cylinder
  • geometry_box
  • geometry_sphere

color

macro

  • color

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

SDFUtils-1.0.0.tar.gz (4.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

SDFUtils-1.0.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file SDFUtils-1.0.0.tar.gz.

File metadata

  • Download URL: SDFUtils-1.0.0.tar.gz
  • Upload date:
  • Size: 4.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for SDFUtils-1.0.0.tar.gz
Algorithm Hash digest
SHA256 915713339e75350cfd66d3f34b5f111abae84344f2b21be0da8205c53e20170a
MD5 2d477f5cd03f03d5122a959a4bfb5f90
BLAKE2b-256 772a581370694c78edc194b3307a5d07309b50e43e8169435c5262f074634bce

See more details on using hashes here.

File details

Details for the file SDFUtils-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: SDFUtils-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.8.5

File hashes

Hashes for SDFUtils-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8d2405eadd44770f46931302821f40880010d3c9c9159ea7f92c5294c9929e32
MD5 4b04bf841548ec4cf077a50943fb25b8
BLAKE2b-256 7d8b0f8b14d34215c6d6613012dab72ca77bb201293864a28aa769fb142c4817

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page