Tools¶
Utility functions for working with robot models.
Emergency stop (teacher tool)¶
Freeze one or more robots from any laptop on the robot's network. It stops every servo directly through the robot's Tinkerforge daemon and latches the stop in every pib3 program connected to the robot.
pib3-estop --host 192.168.0.11 # or: python -m pib3.tools.estop ...
pib3-estop --host pib-01 --host pib-02 # several robots
pib3-estop --host pib-01 --window # a STOP button for these robots
pib3-estop --host pib-01 --relax # servos off - arms drop!
Proto to URDF Converter¶
convert_proto_to_urdf
¶
Convert a Webots .proto file to URDF format.
This is a preprocessing tool for regenerating the URDF from the original Webots robot definition file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
proto_path
|
str
|
Path to the Webots .proto file. |
'pibsim_webots/protos/pib.proto'
|
urdf_path
|
str
|
Path to write the output URDF file. |
'pib_model.urdf'
|
Returns:
| Type | Description |
|---|---|
str
|
The generated URDF as a string. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If proto_path doesn't exist. |
Example
from pib3.tools import convert_proto_to_urdf urdf = convert_proto_to_urdf( ... "pibsim_webots/protos/pib.proto", ... "pib_model.urdf" ... )
Source code in pib3/tools/proto_converter.py
Purpose¶
The PIB robot is originally defined in Webots' .proto format. This tool converts it to URDF (Unified Robot Description Format) for use with roboticstoolbox-python.
Pre-generated URDF
The package includes a pre-generated URDF file. You only need this tool if you modify the Webots proto file.
Usage¶
from pib3.tools import convert_proto_to_urdf
# Convert proto to URDF
urdf_string = convert_proto_to_urdf(
proto_path="pibsim_webots/protos/pib.proto",
urdf_path="pib_model.urdf",
)
print(f"Generated URDF with {urdf_string.count('<link')} links")
Command Line¶
This generates pib_model.urdf from the default proto location.
Conversion Details¶
The converter handles:
| Webots Concept | URDF Equivalent |
|---|---|
Solid |
<link> |
HingeJoint |
<joint type="revolute"> |
Transform |
Visual/collision <origin> |
Shape with Mesh |
<visual> and <collision> |
Physics |
<inertial> |
| Motor limits | <limit> |
Coordinate System¶
The canonical format uses Webots motor radians directly. The URDF generated by this converter uses the same coordinate system as Webots motors.
Example Output¶
<?xml version="1.0"?>
<robot name="pib">
<link name="base_link">
<visual>
<origin xyz="0 0 0" rpy="0 0 0"/>
<geometry><mesh filename="urdf_body.stl"/></geometry>
</visual>
</link>
<joint name="shoulder_vertical_left" type="revolute">
<parent link="base_link"/>
<child link="urdf_shoulder_vertical_1"/>
<origin xyz="0.085 0.055 0.362" rpy="..."/>
<axis xyz="0 1 0"/>
<limit lower="0" upper="3.14" effort="10" velocity="20"/>
</joint>
<!-- ... more links and joints ... -->
</robot>
Calibration Tool¶
For calibrating joint limits on the real robot, see the Calibration Guide.
Internal Utilities¶
Vector Math Functions¶
The proto converter includes internal vector/matrix utilities:
# Not part of public API, but documented for reference:
normalize(v) # Normalize 3D vector
axis_angle_to_matrix() # Convert axis-angle to rotation matrix
matrix_to_rpy() # Convert matrix to roll-pitch-yaw
These are used internally for coordinate transformations during URDF generation.