How To convert [xacro] to [urdf] for Panda robot?
Published:
(20250416).
How To convert [xacro] to [urdf] for Franka Emika Panda robot?
This post describes how you can create .urdf
file from .xacro
file for the Franka Emika Panda robot, based on the officially provided “franka_description (official)”.
Environment:
- ROS1
- rosdistro: noetic
- Ubuntu 20.04.6 LTS
- Source “franka_description (official)”
- Improved “franka_description (teng4)” with Panda
URDF
files inside. - For application of the
URDF
file, please see here for a demo video.
STEP-0: Install Docker
Docker is required for the process of xacro
-> URDF
. The installation is quick and easy. With the Docker, you can also run Franka’s official code to visualize the Panda robot in rviz.
$ sudo apt update
$ sudo apt install docker.io
$ sudo systemctl enable docker
$ sudo systemctl start docker
$ newgrp docker
$ whoami #this will output the USERNAME
$ sudo usermod -aG docker USERNAME
$ groups #should have "docker" as one output
$ sudo reboot #reboot or logout-login the PC is required.
$ docker run hello-world
STEP-1: Create Panda URDF from .xacro, need to do:
(1) Put the original folder “franka_description (official)” into a valid catkin_ws
, ensure the subfolder “scripts” exists, which include the code (create_urdf.sh
etc) will be used to create URDF
files later.
(1.1) Commands for generating URDF
from Franka’s xacro
.
NOTE-1: Docker is required.
NOTE-2: It is better to NOT use abs-path
, it may have problems when using the URDF
later.
# Start the generation of the urdf model
$ ./scripts/create_urdf.sh <robot_id> <ee_id>
# id of the robot model: `fr3`, `fp3`, `fer`, `multi_arm`, `none`
# id of the robot end effector: `franka_hand` (default), `cobot_pump`
# Run the following inside *"USERNAME@RT6958U-NESR:~/catkin_ws4/src/franka_description$"*
$ cd ~/catkin_ws4
$ source devel/setup.bash #required
$ cd ~/catkin_ws4/src/franka_description
# NOTE: It is better to **NOT** use `abs-path`, it may have problems when using the `URDF` later.
$ ./scripts/create_urdf.sh fr3 --robot-ee franka_hand --with-sc --abs-path --no-prefix
$ ./scripts/create_urdf.sh fr3 --robot-ee franka_hand --with-sc --no-prefix
$ ./scripts/create_urdf.sh fp3 --robot-ee franka_hand --with-sc --no-prefix
$ ./scripts/create_urdf.sh fer --robot-ee franka_hand --with-sc --no-prefix
$ ./scripts/create_urdf.sh multi_arm --robot-ee franka_hand --with-sc --no-prefix
(1.2) If cmd in (1.1) does not work, run the following inside “USERNAME@RT6958U-NESR:~/catkin_ws4/src/franka_description$”:
$ python3 ./scripts/create_urdf.py fr3 --robot-ee franka_hand --with-sc --no-prefix
$ python3 ./scripts/create_urdf.py fp3 --robot-ee franka_hand --with-sc --no-prefix
$ python3 ./scripts/create_urdf.py fer --robot-ee franka_hand --with-sc --no-prefix
$ python3 ./scripts/create_urdf.py multi_arm --robot-ee franka_hand --with-sc --no-prefix
$ python3 ./scripts/create_urdf.py fr3 --robot-ee cobot_pump --with-sc --no-prefix
$ python3 ./scripts/create_urdf.py fr3 --robot-ee cobot_pump --with-sc --no-prefix
(2) In the newly generated URDF
file, need to do:
Need to correct one conversion mistake for
"fr3_link8"
->"link8"
.The last two fingers
"prismatic"
->"fixed"
, otherwise it will have few related errors in rviz.
STEP-2: Panda in .rviz file, needs to do:
(1) Link names do not matter, and you can leave them alone.
(2) Robot Description: /panda1/robot_description
(if your publish topic name is /panda1/joint_states
)
(3) Fixed Frame: link0
STEP-3: Panda in .cpp file, need to do:
(1) Ensure the joint names are exactly the same as the ones in the URDF
file.
(2) The publish topic name will be /panda1/joint_states
.
STEP-4: if all ok, double check with:
$ rosrun rqt_tf_tree rqt_tf_tree
(optional) STEP-5: Visualize Panda via Franka’s official code:
It would be interesting to try the officially provided code for visualizing the Panda robot in rviz
, it will have an independent small panel to control each joint angle via a slider.
# Run the following inside "USERNAME@RT6958U-NESR:~/catkin_ws4/src/franka_description$"
$ ./scripts/visualize_franka.sh arm_id:=<robot_id>
$ ./scripts/visualize_franka.sh arm_id:=fr3 #it will show a realistic white franka robot in rviz.
$ ./scripts/visualize_franka.sh arm_id:=fp3 #it will show a realistic black franka robot in rviz.
$ ./scripts/visualize_franka.sh arm_id:=fer #it will show a realistic white franka robot in rviz.
Created on 2025-04-16.