Crate rubullet[][src]

A Rust interface for Bullet physics inspired by PyBullet.

Example

use std::{thread, time::Duration};

use anyhow::Result;
use nalgebra::{Isometry3, Vector3};
use rubullet::*;

fn main() -> Result<()> {
    let mut physics_client = PhysicsClient::connect(Mode::Gui)?;

    physics_client.set_additional_search_path("../rubullet-sys/bullet3/libbullet3/data")?;
    physics_client.set_gravity(Vector3::new(0.0, 0.0, -10.0))?;

    let _plane_id = physics_client.load_urdf("plane.urdf", None)?;

    let cube_start_position = Isometry3::translation(0.0, 0.0, 1.0);
    let box_id = physics_client.load_urdf(
        "r2d2.urdf",
        UrdfOptions {
            base_transform: cube_start_position,
            ..Default::default()
        },
    )?;

    for _ in 0..10000 {
        physics_client.step_simulation()?;
        thread::sleep(Duration::from_micros(4167));
    }

    let cube_transform = physics_client.get_base_transform(box_id)?;
    println!("{}", cube_transform);

    Ok(())
}

Re-exports

pub use image;
pub use nalgebra;

Structs

AddDebugLineOptions

Represents options for add_user_debug_line

AddDebugTextOptions

Represents options for add_user_debug_text

BodyId

The unique ID for a body within a physics server.

BodyInfo

Contains the body name and base name of a Body. BodyInfo is returned by get_body_info

ChangeVisualShapeOptions

This struct keeps the information to change a visual shape with the change_visual_shape method.

CollisionId

The unique ID for a Collision Shape.

Error
Images

Stores the images from get_camera_image()

InverseKinematicsNullSpaceParameters

Parameters for Inverse Kinematics using the Nullspace

InverseKinematicsParameters

Parameters for the calculate_inverse_kinematics() You can easily create them using the InverseKinematicsParametersBuilder

InverseKinematicsParametersBuilder

creates InverseKinematicsParameters using the Builder Pattern which can then be used in calculate_inverse_kinematics(). Use the build() method to get the parameters.

ItemId

The unique ID for a User Debug Parameter Item

Jacobian

Specifies a jacobian with 6 rows. The jacobian is split into a linear part and an angular part.

JointInfo

Contains basic information about a joint like its type and name. It can be obtained via get_joint_info()

JointState

Represents the current state of a joint. It can be retrieved via get_joint_state()

KeyboardEvent

Represents a key press Event

LinkState

Describes the State of a Link

LoadModelFlags

Use flag for loading the model. Flags can be combined with the |-operator. Example:

MouseButtonState

Represents the different possible states of a mouse button

MultiBodyOptions

Specifies all options for create_multi_body. Most of the the time you are probably fine using MultiBodyOptions::default() or just setting the base_pose and/or mass

PhysicsClient

Connection to a physics server.

SdfOptions

Options for loading models from an SDF file into the physics server.

TextureId

The unique ID for a Texture

UrdfOptions

Options for loading a URDF into the physics server.

Velocity

Contains the cartesian velocity stored as Vector with 6 elements (x,y,z,wx,wy,wz).

VisualId

The unique ID for a Visual Shape

VisualShapeData

Contains information about the visual shape of a body. It is returned by get_visual_shape_data

VisualShapeOptions

VisualShape options are for the create_visual_shape function to specify additional options like the color.

Enums

ControlMode

The Control Mode specifies how the robot should move (Position Control, Velocity Control, Torque Control) Each Control Mode has its own set of Parameters. The Position mode for example takes a desired joint position as input. It can be used in set_joint_motor_control()

ControlModeArray

Can be used in set_joint_motor_control_array(). It is basically the same as ControlMode but with arrays. See ControlMode for details.

DebugVisualizerFlag

Flags for configure_debug_visualizer()

ExternalForceFrame

Frame for apply_external_torque() and apply_external_force()

GeometricCollisionShape

Collision shape which can be put the create_collision_shape method

GeometricVisualShape

Visual shapes to put into the create_visual_shape method together with VisualShapeOptions

IkSolver

Specifies which Inverse Kinematics Solver to use in calculate_inverse_kinematics()

JointType

An enum to represent different types of joints

Mode

Ways to connect to physics servers.

MouseEvent

Mouse Events can either be a “Move” or a “Button” event. A “Move” event is when the mouse is moved in the OpenGL window and a “Button” even is when a mouse button is clicked.