Skip to content

stillonearth/bevy_urdf

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

176 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

bevy_urdf

Crates.io Crates.io

A Bevy plugin for importing robots from URDF files and running physics simulations. Ground vehicles use Rapier physics, while drones are simulated using integrated dynamics models.

image image image

Bevy URDF Plugin

A Bevy plugin for loading and simulating robots from URDF files.

Installation

[dependencies]
bevy_urdf = "0.4"

Setup

use bevy::prelude::*;
use bevy_urdf::{UrdfPlugin, StlPlugin, ObjPlugin};

fn main() {
    App::new()
        .add_plugins(DefaultPlugins)
        .add_plugins((UrdfPlugin, StlPlugin, ObjPlugin))
        .run();
}

Loading Robots

use bevy_urdf::{LoadRobot, RobotLoaded, SpawnRobot, RobotType};

fn setup(mut load_robot_events: EventWriter<LoadRobot>) {
    load_robot_events.send(LoadRobot {
        urdf_path: "robots/robot.urdf".to_string(),
        mesh_dir: "assets/robots".to_string(),
    });
}

fn spawn_robot(
    mut robot_loaded_events: EventReader<RobotLoaded>,
    mut spawn_robot_events: EventWriter<SpawnRobot>,
) {
    for event in robot_loaded_events.read() {
        spawn_robot_events.send(SpawnRobot {
            handle: event.handle.clone(),
            mesh_dir: event.mesh_dir.clone(),
            robot_type: RobotType::NotDrone, // or UAV, UUV, Manipulator
        });
    }
}

Control Events

Motor Velocities (ground robots)

ControlMotorVelocities {
    handle: robot_handle,
    velocities: vec![1.0, -1.0, 0.5],
}

Motor Positions (manipulators)

ControlMotorPositions {
    handle: robot_handle,
    positions: vec![0.5, 1.2, -0.3],
    motor_props: motor_properties,
}

Thrusts (drones)

ControlThrusts {
    handle: robot_handle,
    thrusts: vec![10.0, 10.0, 10.0, 10.0],
}

Sensor Reading

SensorsRead {
    handle: robot_handle,
    transforms: link_transforms,
    joint_angles: current_angles,
}

URDF Requirements

  • Use relative mesh paths: meshes/part.stl
  • Remove package:// URIs
  • Remove Gazebo-specific elements
  • Support STL and OBJ mesh formats only

Examples

cargo run --example uav --release
cargo run --example uuv --release
cargo run --example quadruped --release
cargo run --example manipulator --release

About

Import robots from URDF descriptors to bevy and simulate them with Rapier physics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages