urdx
Create URDF robot definitions using JSX
This is essentially a templating engine for rendering URDF files using javascript. This allows:
Programmatic shape definitions.
Mass and inertia tensor can be automatically calculated for standard shapes: Box, Cylinder, Sphere. For example:
<Cylinder ="base" = = />
becomes:
Hierarchies and inheritance.
Define a joint between a parent and child just by making the child a syntactic child of the parent. Also allows children to inherit properties e.g. material of their parent. For example:
<Cylinder ="base" = = => <Box ="child" = = = /></Cylinder>
becomes:
... ...
Mixed XML.
Valid XML is valid JSX. So you can write:
<Cylinder ="base" = = /><link ="child_link"> <visual> <geometry> <box ="0.1 0.1 0.1"/> </geometry> </visual></link><joint ="child_joint" ="fixed"> <parent ="base_link"/> <child ="child_link"/></joint>
Get started
Create a new folder and add this as package.json
:
"name": "my-super-robot" "version": "1.0.0" "description": "My Super Robot Definition" "scripts": "build": "babel urdx -d .urdx" "postbuild": "node .urdx/index.js" "devDependencies": "@babel/cli": "^7.1.0" "@babel/core": "^7.1.0" "@babel/plugin-transform-react-jsx": "^7.1.0" "@babel/preset-env": "^7.1.0" "dependencies": "urdx": "latest" "babel": "plugins": "@babel/plugin-transform-react-jsx" "pragma": "urdx.createElement" "throwIfNamespace": false "presets": "@babel/env"
Then run npm i
. Create directories called urdx
and urdf
, and
then add urdx/index.js
:
; const robot = <Cylinder name="base" length=01 radius=01 /> const files = filename: 'myfirst.urdf' args: name: 'myfirst' robot ; urdx;
Then run npm run build
. Voilà! Your robot will show up in the urdf
folder.
Look in the folder of this project called urdx
to see some more detailed examples!