Skip to main content

parse_urdf/
parse_urdf.rs

1use dynamics_rs::prelude::*;
2
3fn main() {
4    let urdf_path = "./examples/descriptions/ur5/ur5_robot.urdf"; // Path to the URDF file
5    let mesh_path = "./examples/descriptions/ur5/"; // Optional mesh path
6
7    // Build models from the URDF file
8    let (model, _coll_model, _viz_model) =
9        build_models_from_urdf(urdf_path, Some(mesh_path)).expect("Failed to parse URDF file");
10
11    // Print the names of the joints
12    println!("Joints in the model:");
13    for joint_name in &model.joint_names {
14        println!("- {}", joint_name);
15    }
16
17    // Print the names of the frames
18    println!("\nFrames in the model:");
19    for frame in &model.frames {
20        println!("- {}", frame.name);
21    }
22    println!();
23
24    // Print the joint tree
25    model.print_joint_tree().unwrap();
26}