|
bitsim
Model, simulate, estimate and control robots in C++
|
bitsim has robots of two kinds:
The Chrono robot is the one the simulation, estimation and hardware in the loop examples drive; the models are for planning, estimation and control, where the equations themselves are what matters.
| Robot | What it is | Needs | Examples |
|---|---|---|---|
| CHRONO_DiffDriveRobot | a chassis, two driven wheels with DC motors and a ball caster, in Chrono, with its sensors | ENABLE_CHRONO | A differential drive robot in Chrono, Following a line with infrared sensors and avoiding obstacles, Sensor fusion with an extended Kalman filter, A differential drive robot with real motors |
| DiffDriveDynamics | the motion of a differential drive in the plane, with its Jacobians for a Kalman filter | nothing | The kinematics of a differential drive, Extended Kalman filtering |
| BicycleVehicleModelDynamics | the kinematic bicycle model of a car-like vehicle | nothing | |
| QuadrotorDynamics | the 6-DOF rigid body dynamics of a quadrotor, driven by the speeds of its four rotors | nothing | The dynamics of a quadrotor, Flying a simulated quadrotor from the laptop |
| FixedWingDynamics | the 6-DOF flight dynamics of a fixed wing aircraft with a propeller and a landing gear | nothing | A fixed wing UAV: trim, stability, autopilot, takeoff and landing |
CHRONO_DiffDriveRobot is a chassis, two driven wheels and a ball caster. Each driven wheel has a DCMotor, see Actuators, and the robot carries the sensors of Sensors. It is loaded from a robot file, added to a Chrono system, and then driven step by step:
The robot file, robots/bitsim_diff_drive_robot.json, describes the robot. Its sections:
| Section | What |
|---|---|
| name | the name of the robot |
| robot-data | max_speed, the largest speed of a wheel on the ground [m/s], wheel_radius, wheel_width, axle_length, the distance between the wheels, and caster_wheel_radius, all in m, and the density of the parts [kg/m³] |
| material | the friction and the restitution of the contacts |
| chassis | the size of the chassis along x, y and z, chassis_x to chassis_z, and the position of its centre of mass |
| left-wheel, right-wheel, caster-wheel | where each wheel is, relative to the chassis |
| motors | the backend of the wheel motors, SIMULATION, and their parameters, see Actuators |
| sensors | the sensors and their backends, see Sensors |
The chassis, motors and sensors sections have a description that says what their values mean. A changed copy of the file makes a different robot. The examples load the one in robots/ with bitsim::consts::ROBOTS_DIR, or bitsim::consts::build_robot_file_path("bitsim_diff_drive_robot.json"); both are in data_dir(): the directory in the BITSIM_DATA_DIR environment variable if it is set, otherwise the source tree bitsim was built from if it is still there, and otherwise the files an installed bitsim put in share/bitsim.
The vehicle models are the equations of motion of a vehicle, with no physics engine: each takes the state and the inputs and steps them forward.
The differential drive. DiffDriveDynamics moves the centre of the axle at \((x, y)\), facing \(\theta\). In its default version, V1, the input is the speed \(v\) and the turning rate \(\omega\), and over a step the robot drives an exact arc; with no errors that is exact for a constant \(v\) and \(\omega\). It also gives the Jacobians of the step with respect to the state and to the errors, which is what an extended Kalman filter needs, as in Extended Kalman filtering. Its other versions take a forward Euler step, V2 with \(v\) and \(\omega\) and V3 with the speeds of the two wheels.
The bicycle model. BicycleVehicleModelDynamics is the kinematic bicycle model of a car-like vehicle: its position and heading, a wheelbase \(L\) between the front and the rear wheels, and the speed and the steering angle as inputs.
The quadrotor. QuadrotorDynamics is the rigid body dynamics of a quadrotor in a plus layout, driven by the speeds of its four rotors: the thrust \(k_1 \omega_i^2\) of each rotor, the torques of their differences about the three axes, and the drag torque \(k_2 \omega_i^2\) of each rotor about its axis. QuadrotorFlightController flies it in angle mode, from the sticks of a radio transmitter, which Flying a simulated quadrotor from the laptop takes from the laptop's keyboard.
The fixed wing aircraft. FixedWingDynamics is the 6-DOF flight dynamics of a small fixed wing aircraft, after Beard and McLain's Small Unmanned Aircraft: air data with wind, lift that stalls, drag, the side force and the moments, a propeller driven by a DC motor, and a landing gear on the ground. A fixed wing UAV: trim, stability, autopilot, takeoff and landing trims it, designs an autopilot from its linearised dynamics, and flies it from takeoff to landing.