Visualize URDF(Unified Robot Description Format) file.
urdf-viz
is written in Rust-lang.
cargo
If you are using rust-lang already and cargo
is installed, you can install by cargo install
.
bash
cargo install urdf-viz
If you don't use mesh other than .obj
, .stl
, and .dae
files, you can skip install
of assimp by disabling the assimp
feature like below.
bash
cargo install urdf-viz --no-default-features
Note: When the assimp
feature is disabled, materials are not fully supported yet.
You need cmake to use assimp (mesh loader).
It can be skipped if you use --no-default-features
, but it will make it
fail to show mesh files other than .obj
, .stl
, and .dae
.
If you have not installed ROS, you may need cmake
, xorg-dev
, glu
to
compile assimp-sys
and glfw-sys
.
bash
sudo apt-get install cmake xorg-dev libglu1-mesa-dev
You need freetype.lib in your PATH, which is required by freetype-sys
.
You can find binaries here
Install freetype by brew.
bash
brew install freetype
You can download prebuilt binaries from the release page. Prebuilt binaries are available for macOS, Linux, and Windows.
You can install urdf-viz using Homebrew tap on macOS and Linux:
sh
brew install openrr/tap/urdf-viz
urdf-viz
command will be installed.
It needs rosrun
and rospack
to resolve package://
in <mesh>
tag, and
it uses xacro
to convert .xacro
file into urdf file.
It means you need $ source ~/catkin_ws/devel/setup.bash
or something before using urdf-viz
.
bash
urdf-viz URDF_FILE.urdf
It is possible to use xacro file directly.
It will be converted by rosrun xacro xacro
inside of urdf-viz
.
bash
urdf-viz XACRO_FILE.urdf.xacro
For other options, please read the output of -h
option.
bash
urdf-viz -h
If there are no "package://" in mesh tag, and don't use xacro you can skip install of ROS.
If there are "package://" in mesh tag, but path or URL to package is known and don't use xacro you can also skip install of ROS by replacing package with path or URL.
In the GUI, you can do some operations with keyboard and mouse.
l
key to reload the urdf from filec
key to toggle collision model or visual modeUp
/Down
keyCtrl
+ Drag to move the angle of a jointo
([
) and p
(]
)Shift
+ Drag to use inverse kinematics(Y and Z axis)Shift
+ Ctrl
+ Drag to use inverse kinematics(X and Z axis),
or .
r
key to set random jointsz
key to reset joint positions and originYou can set/get the joint angles using http/JSON.
Default port number is 7777. You can change it by -p
option.
(jq
is used for JSON formatter in the following examples)
POST the JSON data, which format is like below. You have to specify the names of joints and positions (angles).
The length of names
and positions
have to be the same. You don't need write
all joint names, it means you can specify a part of the joints.
json
{
"names": ["joint_name1", "joint_name2"],
"positions": [0.5, -0.1]
}
You can try it using curl
.
bash
$ curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"names": ["r_shoulder_yaw", "r_shoulder_pitch"], "positions": [0.8, -0.8]}' http://127.0.0.1:7777/set_joint_positions | jq
{
"is_ok": true,
"reason": ""
}
The result JSON format of getting the joint angles is the same as the Set method.
bash
$ curl http://127.0.0.1:7777/get_joint_positions | jq
{
"names": [
"r_shoulder_yaw",
"r_shoulder_pitch",
"r_shoulder_roll",
"r_elbow_pitch",
"r_wrist_yaw",
"r_wrist_pitch",
"l_shoulder_yaw",
"l_shoulder_pitch",
"l_shoulder_roll",
"l_elbow_pitch",
"l_wrist_yaw",
"l_wrist_pitch"
],
"positions": [
0.8,
-0.8,
-1.3447506,
-1.6683152,
-1.786362,
-1.0689334,
0.11638665,
-0.5987091,
0.7868867,
-0.027412653,
0.019940138,
-0.6975361
]
}
bash
$ curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '{"position":[0.2,0.0,0.0],"quaternion":[0.0,0.0,0.0,1.0]}' http://127.0.0.1:7777/set_robot_origin
{"is_ok":true,"reason":""}
The order of the quaternion elements is w, i, j, k
.
bash
$ curl http://127.0.0.1:7777/get_robot_origin
{"position":[0.2,0.0,0.0],"quaternion":[1.0,0.0,0.0,0.0]}
bash
curl http://127.0.0.1:7777/get_urdf_text
urdf-viz
is strongly depend on kiss3d
, which is super easy to use, great 3D graphic engine.urdf-rs
.kiss3d
supports .obj
files natively, but urdf contains dae
or stl
files. These files are converted to kiss3d mesh model by assimp-rs