|
bitsim
Model, simulate, estimate and control robots in C++
|
A differential-drive robot in Chrono: a chassis, two driven wheels and a ball caster. Each driven wheel has an actuators::DCMotor. More...
#include <diff_drive_robot.h>
Classes | |
| struct | RobotData |
| class | RobotSensorManager |
Public Types | |
| enum | Wheel : uint_t { LEFT = 0 , RIGHT = 1 } |
| The wheels, in the order of the motors. More... | |
| using | json = nlohmann::json |
Public Member Functions | |
| CHRONO_DiffDriveRobot ()=default | |
| Constructor. | |
| void | load (const std::filesystem::path &filename) |
| Load the robot details form the specified filename. | |
| void | load (const json &j) |
| Load the robot details form the specified json structure. | |
| uint_t | n_wheel_motors () const noexcept |
| void | set_motor (uint_t m, std::shared_ptr< actuators::DCMotor > motor) |
| Replace the motor of a wheel. The wheel is reconnected to the chassis to match the backend of the motor. | |
| std::shared_ptr< actuators::DCMotor > | get_motor (uint_t m) const |
| void | set_motor_speed (uint_t m, real_t speed) |
| Set the target speed of the m-th wheel [rad/s] m=0 => left motor m=1 => right motor. | |
| void | set_motor_speed (real_t speed) |
| Set both wheels to the same target speed [rad/s]. | |
| void | set_speed (real_t speed) |
| Drive straight at the given speed [m/s]. | |
| void | set_velocity (real_t v, real_t omega) |
| Drive with a forward speed v [m/s] and a turning rate omega [rad/s], positive to the left. | |
| void | update (real_t dt) |
| Advance the motors by dt and pass their output to the wheels. Call it before every DoStepDynamics(dt). | |
| real_t | wheel_angle (uint_t m) const |
| real_t | wheel_torque (uint_t m) const |
| const CHRONO_RobotPose & | get_pose () const |
| std::shared_ptr< chrono::ChBody > | get_chassis () const |
| std::shared_ptr< chrono::ChBody > | get_wheel (uint_t m) const |
| chrono::ChVector3d | axle_center () const |
| real_t | heading () const |
| void | set_world_pose (real_t x, real_t y, real_t yaw) |
| Move the whole robot so that its axle centre is at (x, y) and it faces yaw. Its height does not change. Use it before the simulation starts: it moves the bodies without changing their velocities. | |
| std::shared_ptr< sensors::UltrasonicSensor > | get_sonar () const noexcept |
| std::shared_ptr< sensors::UltrasonicSensor > | get_rear_sonar () const noexcept |
| std::shared_ptr< sensors::InfraredSensor > | get_line_sensor () const noexcept |
| std::shared_ptr< sensors::IMUSensor > | get_imu () const noexcept |
| void | set_floor (sensors::backends::CHRONO_InfraredBackend::Floor floor) |
| Set the floor that a simulated line-sensor looks at. | |
| std::shared_ptr< sensors::DownwardCamera > | get_camera () const noexcept |
| cv::Mat | camera_view (const sensors::FloorImage &floor) const |
| What the robot's camera sees of the given floor where the robot is now. | |
| const RobotData & | get_data () const noexcept |
| void | add_to_sys (chrono::ChSystemNSC &sys) const |
| RobotSensorManager & | get_sensor_manager () |
| void | set_world_position (const chrono::ChVector3d &position) |
| Explicitly set the world position of the chassis. It moves the chassis only, not the wheels; use set_world_pose to move the robot. | |
| void | set_world_position (const std::array< real_t, 3 > &position) |
| Explicitly set the world position of the chassis. It moves the chassis only, not the wheels; use set_world_pose to move the robot. | |
A differential-drive robot in Chrono: a chassis, two driven wheels and a ball caster. Each driven wheel has an actuators::DCMotor.
How a motor turns its wheel depends on its backend. A simulated motor produces a torque, and Chrono moves the wheel. A real motor on a board has already turned, so Chrono turns the wheel to the angle it reports, and the contact with the ground moves the robot. Either way, call update(dt) before every DoStepDynamics(dt).
The motors come from the "motors" section of the robot file. Without one, or to use real motors, attach them with set_motor() before or after add_to_sys().
| using bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::json = nlohmann::json |
Constructor.
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::add_to_sys | ( | chrono::ChSystemNSC & | sys | ) | const |
Add the components of this robot to the given chrono::ChSystemNSC
| sys |
| chrono::ChVector3d bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::axle_center | ( | ) | const |
| cv::Mat bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::camera_view | ( | const sensors::FloorImage & | floor | ) | const |
What the robot's camera sees of the given floor where the robot is now.
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
| std::shared_ptr< actuators::DCMotor > bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::get_motor | ( | uint_t | m | ) | const |
|
inline |
Get the pose of the robot
|
inlinenoexcept |
|
inline |
Read/write reference to the senosr manager for this robot
|
inlinenoexcept |
| std::shared_ptr< chrono::ChBody > bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::get_wheel | ( | uint_t | m | ) | const |
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::load | ( | const json & | j | ) |
Load the robot details form the specified json structure.
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::load | ( | const std::filesystem::path & | filename | ) |
Load the robot details form the specified filename.
|
inlinenoexcept |
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::set_floor | ( | sensors::backends::CHRONO_InfraredBackend::Floor | floor | ) |
Set the floor that a simulated line-sensor looks at.
| std::logic_error | If the robot has no line-sensor, or its backend is not SIMULATION |
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::set_motor | ( | uint_t | m, |
| std::shared_ptr< actuators::DCMotor > | motor ) |
Replace the motor of a wheel. The wheel is reconnected to the chassis to match the backend of the motor.
Set both wheels to the same target speed [rad/s].
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::set_motor_speed | ( | uint_t | m, |
| real_t | speed ) |
Set the target speed of the m-th wheel [rad/s] m=0 => left motor m=1 => right motor.
Drive straight at the given speed [m/s].
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::set_velocity | ( | real_t | v, |
| real_t | omega ) |
Drive with a forward speed v [m/s] and a turning rate omega [rad/s], positive to the left.
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::set_world_pose | ( | real_t | x, |
| real_t | y, | ||
| real_t | yaw ) |
Move the whole robot so that its axle centre is at (x, y) and it faces yaw. Its height does not change. Use it before the simulation starts: it moves the bodies without changing their velocities.
| x | The x coordinate of the axle centre [m] |
| y | The y coordinate of the axle centre [m] |
| yaw | The heading, see heading() [rad] |
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::set_world_position | ( | const chrono::ChVector3d & | position | ) |
Explicitly set the world position of the chassis. It moves the chassis only, not the wheels; use set_world_pose to move the robot.
| position |
| void bitsim::rb::bitsim_chrono::CHRONO_DiffDriveRobot::set_world_position | ( | const std::array< real_t, 3 > & | position | ) |
Explicitly set the world position of the chassis. It moves the chassis only, not the wheels; use set_world_pose to move the robot.
| position |
Advance the motors by dt and pass their output to the wheels. Call it before every DoStepDynamics(dt).