bevy_urdf

Crates.iobevy_urdf
lib.rsbevy_urdf
version
sourcesrc
created_at2025-03-21 08:14:36.659342+00
updated_at2025-04-05 17:47:47.760575+00
descriptionImport robots from URDF files and run simulation with rapier.
homepage
repositoryhttps://github.com/stillonearth/bevy_urdf
max_upload_size
id1600270
Cargo.toml error:TOML parse error at line 17, column 1 | 17 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include`
size0
Sergei Surovtsev (stillonearth)

documentation

README

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
Commit count: 0

cargo fmt