Crate rubullet[][src]

Expand description

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;

Modules

logging_utils

Contains methods and types which are useful for logging

Structs

Aabb

axis-aligned minimum bounding box

ActivationState
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

CameraImageOptions

Options for get_camera_image

ChangeConstraintOptions

contains the parameters for change_constraint method.

ChangeDynamicsOptions

Dynamics options for the change_dynamics method. Some options do not depend on the given link and apply to the whole body. These options are:

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.

ConstraintId

The unique ID for a constraint.

ConstraintInfo

contains the parameters for change_constraint method.

ContactPoint

Is the result of the get_closest_points and get_contact_points methods.

DebugVisualizerCameraInfo

Contains the state of the Gui camera. Is returned by get_debug_visualizer_camera.

DynamicsInfo

Contains information about the mass, center of mass, friction and other properties of the base and links. Is returned by get_dynamics_info.

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:

LogFlags
LogId

The unique ID for a Logging Object.

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

OverlappingObject

Is the result of get_overlapping_objects. Each object specifies a link of a body.

PhysicsClient

Connection to a physics server.

PhysicsEngineParameters

See SetPhysicsEngineParameterOptions for a description of the parameters.

PhysicsServer

A PhysicsServer is actually a PhysicsClient which is run as a TCP Server and with all methods apart from is_connected disabled, as they would fail otherwise. This is for advanced users and you are usually you should be better of with a normal PhysicsClient.

RayHitInfo
RayTestBatchOptions

Options for ray_test_batch

RayTestOptions

Options for ray_test

RendererAuxFlags

flags for camera rendering

ResetFlags

Experimental flags, best to ignore.

SdfOptions

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

SetPhysicsEngineParameterOptions

Options for the set_physics_engine_parameter method.

SoftBodyOptions

options for load_soft_body

StateId

The unique ID for a State Object.

StateLoggingOptions
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

VisualShapeFlags

Experimental flags, best to ignore.

VisualShapeOptions

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

Enums

BodyType
ConstraintSolverType
ControlCommand

The ControlCommand specifies how the robot should move (Position Control, Velocity Control, Torque Control) Each type of ControlCommand 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()

ControlCommandArray

Can be used in set_joint_motor_control_array(). It is basically the same as ControlCommand but with arrays. See ControlCommand 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()

JointFeedbackMode

Specifies joint feedback frame. Is used in SetPhysicsEngineParameterOptions::joint_feedback_mode

JointType

An enum to represent different types of joints

LoggingType
Mode

Ways to connect to physics clients.

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.

Renderer
ServerMode

Choose which type of server you want.