Urdf File Macro + New Dimensions

This commit is contained in:
2026-11-04 21:09:41 +01:00
parent 6dae4519e3
commit de055dbf93
3 changed files with 170 additions and 1 deletions
+158
View File
@@ -0,0 +1,158 @@
<?xml version="1.0"?>
<robot name="JackBot" xmlns:xacro="http://www.ros.org/wiki/xacro">
<xacro:property name="coxa_length" value="0.0627"/>
<xacro:property name="coxa_diagonal_x" value="0.098574"/>
<xacro:property name="coxa_diagonal_y" value="0.068584"/>
<xacro:property name="coxa_center_x" value="0"/>
<xacro:property name="coxa_center_y" value="0.08565"/>
<xacro:property name="femur_length" value="0.0602"/>
<xacro:property name="tibia_length" value="0.08055"/>
<xacro:property name="leg_radius" value="0.005"/>
<xacro:property name="tip_radius" value="0.01"/>
<xacro:property name="base_size" value="0.200 0.140 0.090"/>
<xacro:property name="joint_lower_limit" value="0.2618"/>
<xacro:property name="joint_upper_limit" value="2.8798"/>
<xacro:property name="joint_effort" value="1"/>
<xacro:property name="joint_velocity" value="1"/>
<xacro:macro name="default_inertial" params="">
<inertial>
<origin xyz="0 0 0" rpy="0 0 0"/>
<mass value="1"/>
<inertia
ixx="0.001" ixy="0" ixz="0"
iyy="0.001" iyz="0"
izz="0.001"/>
</inertial>
</xacro:macro>
<link name="base_link">
<xacro:default_inertial/>
<visual>
<geometry>
<box size="${base_size}"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="red">
<color rgba="1 0 0 0.5"/>
</material>
</visual>
<collision>
<geometry>
<box size="${base_size}"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
</collision>
</link>
<xacro:macro name="leg" params="id x y yaw femur_roll">
<link name="leg${id}_coxa">
<xacro:default_inertial/>
<visual>
<geometry>
<cylinder length="${coxa_length}" radius="${leg_radius}"/>
</geometry>
<origin xyz="${coxa_length / 2} 0 0" rpy="0 1.5708 0"/>
<material name="green">
<color rgba="0 1 0 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="${coxa_length}" radius="${leg_radius}"/>
</geometry>
<origin xyz="${coxa_length / 2} 0 0" rpy="0 1.5708 0"/>
</collision>
</link>
<joint name="leg${id}_coxa_joint" type="revolute">
<parent link="base_link"/>
<child link="leg${id}_coxa"/>
<origin xyz="${x} ${y} 0" rpy="0 0 ${yaw}"/>
<axis xyz="0 0 1"/>
<limit lower="${joint_lower_limit}" upper="${joint_upper_limit}" effort="${joint_effort}" velocity="${joint_velocity}"/>
</joint>
<link name="leg${id}_femur">
<xacro:default_inertial/>
<visual>
<geometry>
<cylinder length="${femur_length}" radius="${leg_radius}"/>
</geometry>
<origin xyz="0 0 -${femur_length / 2}" rpy="0 0 0"/>
<material name="blue">
<color rgba="0 0 1 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="${femur_length}" radius="${leg_radius}"/>
</geometry>
<origin xyz="0 0 -${femur_length / 2}" rpy="0 0 0"/>
</collision>
</link>
<joint name="leg${id}_femur_joint" type="revolute">
<parent link="leg${id}_coxa"/>
<child link="leg${id}_femur"/>
<origin xyz="${coxa_length} 0 0" rpy="${femur_roll} 0 0"/>
<axis xyz="0 -1 0"/>
<limit lower="${joint_lower_limit}" upper="${joint_upper_limit}" effort="${joint_effort}" velocity="${joint_velocity}"/>
</joint>
<link name="leg${id}_tibia">
<xacro:default_inertial/>
<visual>
<geometry>
<cylinder length="${tibia_length}" radius="${leg_radius}"/>
</geometry>
<origin xyz="${tibia_length / 2} 0 0" rpy="0 1.5708 0"/>
<material name="yellow">
<color rgba="0 1 1 1"/>
</material>
</visual>
<collision>
<geometry>
<cylinder length="${tibia_length}" radius="${leg_radius}"/>
</geometry>
<origin xyz="${tibia_length / 2} 0 0" rpy="0 1.5708 0"/>
</collision>
</link>
<joint name="leg${id}_tibia_joint" type="revolute">
<parent link="leg${id}_femur"/>
<child link="leg${id}_tibia"/>
<origin xyz="0 0 -${femur_length}" rpy="0 0 0"/>
<axis xyz="0 1 0"/>
<limit lower="${joint_lower_limit}" upper="${joint_upper_limit}" effort="${joint_effort}" velocity="${joint_velocity}"/>
</joint>
<link name="leg${id}_tip">
<xacro:default_inertial/>
<visual>
<geometry>
<sphere radius="${tip_radius}"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
<material name="purple">
<color rgba="1 0 1 1"/>
</material>
</visual>
<collision>
<geometry>
<sphere radius="${tip_radius}"/>
</geometry>
<origin xyz="0 0 0" rpy="0 0 0"/>
</collision>
</link>
<joint name="leg${id}_tip_joint" type="fixed">
<parent link="leg${id}_tibia"/>
<child link="leg${id}_tip"/>
<origin xyz="${tibia_length} 0 0" rpy="0 0 0"/>
</joint>
</xacro:macro>
<xacro:leg id="1" x="${coxa_diagonal_x}" y="${coxa_diagonal_y}" yaw="-0.7854" femur_roll="0"/>
<xacro:leg id="2" x="${coxa_center_x}" y="${coxa_center_y}" yaw="0" femur_roll="0"/>
<xacro:leg id="3" x="-${coxa_diagonal_x}" y="${coxa_diagonal_y}" yaw="0.7854" femur_roll="0"/>
<xacro:leg id="4" x="-${coxa_diagonal_x}" y="-${coxa_diagonal_y}" yaw="2.3562" femur_roll="3.1416"/>
<xacro:leg id="5" x="${coxa_center_x}" y="-${coxa_center_y}" yaw="3.1416" femur_roll="3.1416"/>
<xacro:leg id="6" x="${coxa_diagonal_x}" y="-${coxa_diagonal_y}" yaw="-2.3562" femur_roll="3.1416"/>
</robot>
+11 -1
View File
@@ -113,7 +113,17 @@ The repository contains a few pieces that are still present but not fully connec
* **Python:** 3.12 recommended * **Python:** 3.12 recommended
* **OS:** Windows 10/11 or Linux * **OS:** Windows 10/11 or Linux
* **Dependencies:** `pybullet`, `gymnasium`, `stable-baselines3`, `torch`, `numpy`, `pygame`, `ikpy`, `pyserial`, `matplotlib`, `dearpygui` * **Dependencies:** `pybullet`, `gymnasium`, `stable-baselines3`, `torch`, `numpy`, `pygame`, `ikpy`, `pyserial`, `matplotlib`, `dearpygui`, `xacro`
## Robot model
Edit [`JackBotUrdf.xacro`](JackBotUrdf.xacro), which defines shared leg dimensions, coxa starting-position properties, and a reusable leg macro. Regenerate the checked-in URDF after changing the model:
```bash
xacro JackBotUrdf.xacro -o JackBotUrdf.urdf
```
The `xacro` dependency is included in `requirements.txt`. Keep `JackBotUrdf.urdf` as generated output; the simulator and kinematics continue loading that file.
--- ---
+1
View File
@@ -13,3 +13,4 @@ stable-baselines3[extra]
gymnasium gymnasium
shimmy shimmy
tensorboard tensorboard
xacro