#bevy #urdf #rapier

bevy_urdf

Import robots from URDF files and run simulation with rapier

12 releases

new 0.1.5 Apr 23, 2025
0.1.4 Apr 18, 2025
0.0.7 Apr 2, 2025
0.0.6 Mar 31, 2025

#86 in Robotics

Download history 329/week @ 2025-03-20 174/week @ 2025-03-27 541/week @ 2025-04-03 115/week @ 2025-04-10 228/week @ 2025-04-17

1,063 downloads per month

MIT/Apache

7.5MB
631 lines

bevy_urdf

Import robots from URDF files and run simulation with rapier.

API

  1. Add Urdf and Stl plugins to bevy app
UrdfPlugin,
StlPlugin,
  1. Load robot in your startup systems

fn setup(mut ew_load_robot: EventWriter<LoadRobot>,) {
...
ew_load_robot.send(LoadRobot {
    urdf_path: "robots/flamingo_edu/urdf/Edu_v4.urdf".to_string(),
    mesh_dir: "assets/robots/flamingo_edu/urdf".to_string(),
});
...
}
  1. Subscribe to loaded event and emit spawn event
fn start_simulation(
    mut er_robot_loaded: EventReader<RobotLoaded>,
    mut ew_spawn_robot: EventWriter<SpawnRobot>,
    mut state: ResMut<NextState<AppState>>,
) {
    for event in er_robot_loaded.read() {
        ew_spawn_robot.send(SpawnRobot {
            handle: event.handle.clone(),
            mesh_dir: event.mesh_dir.clone(),
        });
        state.set(AppState::Simulation);
    }
}

Events

Read sensors and control motors through events:


#[derive(Event)]
pub struct SensorsRead {
    pub handle: Handle<UrdfAsset>,
    pub transforms: Vec<Transform>,
    pub joint_angles: Vec<f32>,
}

#[derive(Event)]
pub struct ControlMotors {
    pub handle: Handle<UrdfAsset>,
    pub velocities: Vec<f32>,
}

Limitations

You may need to hand-inspect urdf files to ensure mesh links are relative to urdf file. package:// and links and gazebo nodes are not supported.

Examples

cargo run --example simulate --release

Dependencies

~71–110MB
~2M SLoC