-
Notifications
You must be signed in to change notification settings - Fork 27
/
xacro2sdf.bash
executable file
·30 lines (25 loc) · 1011 Bytes
/
xacro2sdf.bash
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/usr/bin/env bash
# This script converts xacro (URDF variant) into SDF for `panda_description` package
SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" &>/dev/null && pwd)"
XACRO_PATH="$(dirname "${SCRIPT_DIR}")/urdf/panda.urdf.xacro"
SDF_PATH="$(dirname "${SCRIPT_DIR}")/panda/model.sdf"
TMP_URDF_PATH="/tmp/panda_tmp.urdf"
# Arguments for xacro
XACRO_ARGS=(
name:=panda
gripper:=true
collision_arm:=true
collision_gripper:=true
ros2_control:=true
ros2_control_plugin:=ign
ros2_control_command_interface:=effort
gazebo_preserve_fixed_joint:=false
)
# Remove old SDF file
rm "${SDF_PATH}" 2>/dev/null
# Process xacro into URDF, then convert URDF to SDF and edit the SDF to use relative paths for meshes
xacro "${XACRO_PATH}" "${XACRO_ARGS[@]}" -o "${TMP_URDF_PATH}" &&
ign sdf -p "${TMP_URDF_PATH}" | sed "s/model:\/\/panda_description\///g" >"${SDF_PATH}" &&
echo "Created new ${SDF_PATH}"
# Remove temporary URDF file
rm "${TMP_URDF_PATH}" 2>/dev/null