Each wheel's motor is a DC gear motor with an encoder on its output shaft, like the motors of A differential drive robot with real motors. The encoder has 660 counts a turn, so it measures the wheel's angle in steps of \(2\pi/660\), about half a degree. DCMotor::encoder_angle gives that angle, in whole counts, as a board would know it:
The encoder is on the motor, as it is on a real robot, so there is no separate sensor for it: the robot reads robot.get_motor(m)->encoder_angle() for each wheel, at the same rate as its IMU.
\[\Delta s = \frac{r\,(\Delta\theta_L + \Delta\theta_R)}{2}, \qquad
\Delta\psi = \frac{r\,(\Delta\theta_R - \Delta\theta_L)}{L}
\]
\[x \mathrel{+}= \Delta s \cos\bar\psi, \qquad y \mathrel{+}= \Delta s \sin\bar\psi, \qquad
\bar\psi = \psi + \tfrac{1}{2}\Delta\psi
\]
The heading can come from the wheels, \(\psi \mathrel{+}= \Delta\psi\), or from another sensor. The robot runs both:
Both start from where the robot is placed, as a real robot is placed on its start line.
After the detour the robot crosses the line and drives on by 0.34 m, the distance from its infrared elements to its axle, until the wheels are over the line; then it turns onto it. That distance now comes from the encoders: the Driver notes distance() when the middle element finds the line and drives on until it has grown by 0.34 m. Everything else is as in Turning by the gyroscope of an IMU.
A heading error is the worst of them, because every step after it goes in a slightly wrong direction and the position error grows with the distance driven. The gyroscope does not care about the wheels, so its heading has none of those errors; it has its own, the bias, which Turning by the gyroscope of an IMU takes off.
The odometry columns follow the true pose to a few millimetres, and the robot drove the lap exactly as in Turning by the gyroscope of an IMU. Here the wheels' heading did better than the gyroscope's: 0.08 degrees off after 14 m, against the gyroscope's 0.8. That is the simulation being kind: its wheels hardly slip, and the odometry knows their radius and axle length exactly. With an axle length that is 2 % off, --axle-error 2:
The wheels' heading is off by \(2\pi \cdot 0.02 / 1.02\) = 7.1 degrees after the lap, and the position by 24 cm; the odometry with the gyroscope's heading does not change. That is why robots take their heading from a gyroscope and their distance from their wheels.
#include <chrono/physics/ChBodyEasy.h>
#include <chrono/physics/ChContactMaterialNSC.h>
#include <chrono/physics/ChSystemNSC.h>
#include <chrono_irrlicht/ChVisualSystemIrrlicht.h>
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <memory>
#include <optional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <thread>
#include <vector>
{
using Point = std::array<real_t, 2>;
const std::string
WINDOW_TITLE =
"Odometry from the wheel encoders";
{
}
{
public:
{
};
{
switch (state_)
{
{
++n_detours_;
return command(ir, sonar, driven, heading, dt);
}
return follower_.command(ir, dt);
if (turn_towards_(heading))
{
return {0.0, -pivot_rate_(heading)};
}
[[fallthrough]];
if (ir.is_dark(middle_(ir)))
{
cross_from_ = driven;
return command(ir, sonar, driven, heading, dt);
}
if (driven - cross_from_ < ir_ahead_)
{
}
[[fallthrough]];
if (!ir.is_dark(middle_(ir)) || ir.is_dark(ir.n_elements() - 1))
{
}
return follower_.command(ir, dt);
}
return {};
}
bool has_given_up()
const {
return follower_.has_given_up(); }
private:
static uint_t middle_(
const InfraredSensor &ir) {
return ir.n_elements() / 2; }
bool turn_towards_(
real_t heading)
const
{
return std::abs(std::remainder(turn_to_ - heading, 2.0 *
PI)) > 0.02;
}
{
const real_t error = std::abs(std::remainder(turn_to_ - heading, 2.0 *
PI));
}
};
{
switch (state)
{
return "follow";
return "turn away";
return "detour";
return "cross";
return "align";
}
return "";
}
{
public:
explicit World(
const FloorImage &floor)
{
system_.SetGravitationalAcceleration(
system_.SetCollisionSystemType(chrono::ChCollisionSystem::Type::BULLET);
system_.SetSolverType(chrono::ChSolver::Type::BARZILAIBORWEIN);
system_.GetSolver()->AsIterative()->SetMaxIterations(40);
auto material = chrono_types::make_shared<chrono::ChContactMaterialNSC>();
material->SetFriction(0.8f);
material->SetRestitution(0.1f);
ground_ = chrono_types::make_shared<chrono::ChBodyEasyBox>(20.0, 20.0, 0.1, 1000.0, true,
true, material);
ground_->SetPos(chrono::ChVector3d(0.0, 0.0, -0.05));
ground_->SetFixed(true);
ground_->GetVisualShape(0)->SetColor(chrono::ChColor(0.45f, 0.45f, 0.42f));
system_.Add(ground_);
{
auto box = chrono_types::make_shared<chrono::ChBodyEasyBox>(
box->SetFixed(true);
box->GetVisualShape(0)->SetColor(chrono::ChColor(0.85f, 0.45f, 0.1f));
system_.Add(box);
obstacles_.push_back(box);
}
contacts_ = std::make_shared<ContactCounter>(obstacles_);
if (!robot_.get_line_sensor() || !robot_.get_sonar() || !robot_.get_imu())
{
throw std::runtime_error(
"The robot file " +
ROBOT_FILE +
" needs a line-sensor, a front-sonar and an imu");
}
robot_.set_floor([&floor](
real_t x,
real_t y) {
return floor.reflectance(x, y); });
robot_.add_to_sys(system_);
}
{
touching_ = contacts_->count(system_) > 0;
}
{
texture);
}
real_t time()
const {
return system_.GetChTime(); }
Point position()
const {
return {robot_.axle_center().x(), robot_.axle_center().y()}; }
CHRONO_DiffDriveRobot &
robot() {
return robot_; }
const CHRONO_DiffDriveRobot &
robot()
const {
return robot_; }
chrono::ChSystemNSC &
system() {
return system_; }
{
const auto &elements = robot_.
get_line_sensor()->infrared_backend()->elements();
const auto &e = elements[elements.size() / 2];
const auto chassis = robot_.get_chassis();
const auto world = chassis->GetFrameRefToAbs().TransformPointLocalToParent(
chrono::ChVector3d(e[0], e[1], e[2]));
const auto ahead = world - robot_.axle_center();
return ahead.x() * std::cos(
heading()) + ahead.y() * std::sin(
heading());
}
private:
chrono::ChSystemNSC system_;
std::shared_ptr<chrono::ChBodyEasyBox> ground_;
std::vector<std::shared_ptr<chrono::ChBody>> obstacles_;
std::shared_ptr<ContactCounter> contacts_;
CHRONO_DiffDriveRobot robot_;
bool touching_{false};
};
{
public:
Display(World &world,
const FloorImage &floor,
const std::string &record)
{
texture_ =
(std::filesystem::temp_directory_path() / "bitsim_wheel_odometry_floor.png").string();
floor.write_texture(texture_);
world_.show_floor(texture_);
vis_.AttachSystem(&world_.system());
vis_.SetWindowSize(1280, 720);
vis_.SetCameraVertical(chrono::CameraVerticalDir::Z);
vis_.Initialize();
vis_.AddCamera({0.0, -3.4, 3.0}, {0.0, -0.1, 0.0});
vis_.AddLightDirectional(60.0, 60.0, chrono::ChColor(0.45f, 0.45f, 0.45f),
chrono::ChColor(0.05f, 0.05f, 0.05f),
chrono::ChColor(0.55f, 0.55f, 0.55f));
}
bool show(
const InfraredSensor &ir,
real_t sonar,
const GyroHeading &heading,
real_t gyro_z,
const DiffDriveOdometry &odometry, const DiffDriveOdometry &wheels_only,
{
if (!vis_.Run())
{
return false;
}
vis_.BeginScene();
vis_.Render();
wheels_only_trail_.draw(vis_, chrono::ChColor(0.0f, 0.8f, 0.9f), 2.0);
odometry_trail_.draw(vis_, chrono::ChColor(0.9f, 0.1f, 0.9f), 2.0);
true_trail_.draw(vis_, chrono::ChColor(1.0f, 0.8f, 0.0f), 1.0);
draw_sonar_(sonar);
draw_robot_view_();
draw_text_(ir, sonar, heading, gyro_z, odometry, wheels_only, driver, command, lap);
vis_.EndScene();
recorder_.record(vis_, world_.time());
return true;
}
{
true_trail_.add(truth[0], truth[1]);
odometry_trail_.add(odometry[0], odometry[1]);
wheels_only_trail_.add(wheels_only[0], wheels_only[1]);
}
private:
void draw_sonar_(
real_t sonar)
{
const auto chassis = world_.robot().get_chassis();
const auto &
frame = chassis->GetFrameRefToAbs();
const auto sonar_backend =
std::dynamic_pointer_cast<bitsim::sensors::backends::CHRONO_UltrasonicBackend>(
world_.robot().get_sonar()->range_backend());
const chrono::ChVector3d
start =
frame.TransformPointLocalToParent(
sonar_backend ? sonar_backend->position() : chrono::ChVector3d(0.27, 0, 0.05));
const chrono::ChVector3d dir =
frame.TransformDirectionLocalToParent({1.0, 0.0, 0.0});
const auto colour = sonar <
STOP_DISTANCE ? chrono::ChColor(1.0f, 0.1f, 0.1f)
: chrono::ChColor(0.2f, 0.8f, 0.2f);
}
void draw_robot_view_()
{
const auto &
frame = world_.robot().get_chassis()->GetFrameRefToAbs();
const chrono::ChVector3d look =
frame.TransformDirectionLocalToParent(
const chrono::ChVector3d target = eye + look;
robot_camera_->draw(eye, target);
}
void draw_text_(
const InfraredSensor &ir,
real_t sonar,
const GyroHeading &heading,
real_t gyro_z,
const DiffDriveOdometry &odometry,
const DiffDriveOdometry &wheels_only, const Driver &driver,
{
(void)command;
(void)gyro_z;
const Point p = world_.position();
std::ostringstream text;
text << std::fixed << std::setprecision(1) << "t " << world_.time() << " s lap "
<< 100.0 *
lap <<
" % infrared " << ir.pattern() <<
" sonar "
<< std::setprecision(2) << sonar << " m heading: imu " << std::setprecision(1)
<< heading.heading() * 180.0 /
PI <<
", true " << world_.heading() * 180.0 /
PI
<< " deg odometry off by: gyro heading " << std::setprecision(2)
<< std::hypot(odometry.pose().x - p[0], odometry.pose().y - p[1])
<< " m (magenta), wheel heading "
<< std::hypot(wheels_only.pose().x - p[0], wheels_only.pose().y - p[1])
<< " m (cyan) "
<< (heading.is_calibrating() ? std::string(
"calibrating") :
to_string(driver.state()))
<< " detours " << driver.n_detours();
}
World &world_;
FrameRecorder recorder_;
std::string texture_;
chrono::irrlicht::ChVisualSystemIrrlicht vis_;
std::optional<InsetCamera> robot_camera_;
};
{
};
{
for (int i = 1; i < argc; ++i)
{
const std::string arg = argv[i];
if (arg == "--render")
{
options.render = true;
}
else if (arg == "--axle-error" && i + 1 < argc)
{
options.axle_error = std::stod(argv[++i]);
}
else if (arg == "--no-calibration")
{
options.calibrate = false;
}
else if (arg == "--record" && i + 1 < argc)
{
options.record = argv[++i];
options.render = true;
}
else
{
std::cout << "Usage: wheel_odometry [--render] [--record DIR] [--no-calibration] "
"[--axle-error PERCENT]\n"
<< " --render show the simulation in a window, in real time\n"
<<
" --record DIR also write the window to DIR, " <<
RECORD_RATE
<< " frames a second\n"
<< " --no-calibration do not measure the gyro's bias before driving\n"
<< " --axle-error P odometry takes the wheels to be P % further apart"
<< std::endl;
std::exit(arg == "--help" || arg == "-h" ? 0 : 1);
}
}
return options;
}
{
auto &robot = world.robot();
auto &ir = *robot.get_line_sensor();
auto &sonar = *robot.get_sonar();
auto &imu = *robot.get_imu();
std::optional<Display> display;
if (options.render)
{
display.emplace(world, floor, options.record);
}
Driver driver(world.ir_ahead());
const auto &data = robot.get_data();
const real_t axle_length = data.axle_length * (1.0 + 0.01 * options.axle_error);
odometry.reset(start, left->encoder_angle(), right->encoder_angle());
wheels_only.reset(start, left->encoder_angle(), right->encoder_angle());
std::cout << std::fixed << std::setprecision(2) <<
"Track " << 2 *
TRACK_HALF_LENGTH <<
" x "
<< "Infrared: " << ir.n_elements() << " elements, " << world.ir_ahead()
<< " m ahead of the axle, " << 1.0 / ir.backend_ptr()->sampling_period()
<< " readings/s\n"
<< "Sonar: " << sonar.range_backend()->min_distance() << " to "
<< sonar.range_backend()->max_distance() << " m, "
<< 1.0 / sonar.backend_ptr()->sampling_period() << " readings/s\n"
<< "IMU: " << 1.0 / imu.backend_ptr()->sampling_period() << " readings/s, "
<< (options.calibrate ? "measures the gyro's bias first" : "no calibration") << "\n"
<< "Encoders: " << data.wheel_radius << " m wheels, " << data.axle_length
<< " m apart; odometry takes them to be " << std::setprecision(3) << axle_length
<< " m apart\n\n"
<< std::setprecision(2)
<< " t [s] x [m] y [m] head [deg] imu [deg] odo x [m] odo y [m] infrared"
" sonar [m] state \n";
const real_t ir_period = ir.backend_ptr()->sampling_period();
const real_t sonar_period = sonar.backend_ptr()->sampling_period();
const real_t imu_period = imu.backend_ptr()->sampling_period();
bool was_touching = false;
bool completed = false;
bool stopped = false;
bool gave_up = false;
real_t max_heading_error = 0.0;
real_t max_odometry_error = 0.0;
real_t max_wheels_only_error = 0.0;
const auto wall_start = std::chrono::steady_clock::now();
{
if (world.time() + 1e-9 >= next_imu)
{
next_imu += imu_period;
imu.read_values();
heading.update(imu.angular_velocity()[2], imu_period);
odometry.update(left->encoder_angle(), right->encoder_angle(), heading.heading());
wheels_only.update(left->encoder_angle(), right->encoder_angle());
}
if (world.time() + 1e-9 >= next_sonar)
{
next_sonar += sonar_period;
sonar.read_values();
}
if (world.time() + 1e-9 >= next_ir)
{
next_ir += ir_period;
ir.read_values();
: driver.command(ir, sonar.distance(), odometry.distance(),
heading.heading(), ir_period);
if (driver.has_given_up())
{
gave_up = true;
std::cout <<
"\nThe robot lost the line for " <<
LOST_TIME <<
" s and stops"
<< std::endl;
break;
}
}
world.step(command);
const Point p = world.position();
const real_t angle = std::atan2(p[1], p[0]);
travelled_angle += std::remainder(angle - last_angle, 2.0 *
PI);
last_angle = angle;
{
if (driver.is_lost())
{
longest_lost = std::max(longest_lost, lost_since);
}
else
{
lost_since = 0.0;
}
}
if (world.is_touching_an_obstacle() && !was_touching)
{
++n_hits;
std::cout << " the robot touches a box at t = " << world.time() << " s" << std::endl;
}
was_touching = world.is_touching_an_obstacle();
const real_t heading_error = std::remainder(heading.heading() - world.heading(), 2.0 *
PI);
max_heading_error = std::max(max_heading_error, std::abs(heading_error));
const auto &o = odometry.pose();
const auto &w = wheels_only.pose();
max_odometry_error = std::max(max_odometry_error, std::hypot(o.x - p[0], o.y - p[1]));
max_wheels_only_error = std::max(max_wheels_only_error, std::hypot(w.x - p[0], w.y - p[1]));
if (display)
{
display->add_to_trails(p, {o.x, o.y}, {w.x, w.y});
}
if (world.time() + 1e-9 >= next_print)
{
std::cout << std::setw(9) << std::setprecision(2) << world.time()
<< std::setprecision(3) << std::setw(8) << p[0] << std::setw(8) << p[1]
<< std::setw(12) << std::setprecision(1) << world.heading() * 180.0 /
PI
<< std::setw(11) << heading.heading() * 180.0 /
PI << std::setprecision(3)
<< std::setw(11) << o.x << std::setw(11) << o.y << std::setw(10)
<< ir.pattern() << std::setw(11) << std::setprecision(2) << sonar.distance()
<< " " << std::left << std::setw(11)
<< (heading.is_calibrating() ?
"calibrate" :
to_string(driver.state()))
<< std::right << std::endl;
}
if (display && world.time() + 1e-9 >= next_frame)
{
if (!display->show(ir, sonar.distance(), heading, imu.angular_velocity()[2], odometry,
wheels_only, driver, command,
std::clamp(travelled_angle / (2.0 *
PI), 0.0, 1.0)))
{
stopped = true;
break;
}
const real_t ahead = world.time() - std::chrono::duration<real_t>(
std::chrono::steady_clock::now() - wall_start)
.count();
if (ahead > 0.0)
{
std::this_thread::sleep_for(std::chrono::duration<real_t>(ahead));
}
}
if (travelled_angle >= 2.0 *
PI)
{
completed = true;
break;
}
}
std::chrono::duration<real_t>(std::chrono::steady_clock::now() - wall_start).count();
std::cout << std::setprecision(2) << "\n"
<< (completed ? "The robot went once around the track"
: stopped ? "Stopped"
: gave_up ? "The robot lost the line"
: "The robot did not get around the track")
<< " in " << world.time() << " s of simulation, " << wall_time << " s of wall time\n"
<<
"Detours around boxes: " << driver.n_detours() <<
" of " <<
OBSTACLES.size()
<< ", times it touched a box: " << n_hits << "\n"
<< "While following the line, the elements saw it "
<< 100.0 * (1.0 - lost_time / std::max(follow_time,
STEP_SIZE))
<< " % of the time; the longest time without it was " << longest_lost << " s\n";
const auto imu_backend =
std::dynamic_pointer_cast<bitsim::sensors::backends::CHRONO_IMUBackend>(imu.imu_backend());
if (imu_backend)
{
std::cout << std::setprecision(4)
<< "Gyro bias about z: " << imu_backend->errors().gyro_bias[2]
<< " rad/s, measured " << heading.bias() << " rad/s\n";
}
std::cout << std::setprecision(2) << "Heading from the gyro: off by "
<< std::remainder(heading.heading() - world.heading(), 2.0 *
PI) * 180.0 /
PI
<<
" deg at the end, at most " << max_heading_error * 180.0 /
PI <<
" deg\n";
const Point p = world.position();
const auto &o = odometry.pose();
const auto &w = wheels_only.pose();
std::cout << std::setprecision(3) << "Odometry, " << odometry.distance()
<< " m driven by the encoders:\n"
<< " heading from the gyro: off by " << std::hypot(o.x - p[0], o.y - p[1])
<< " m at the end, at most " << max_odometry_error << " m\n"
<< " heading from the wheels: off by " << std::hypot(w.x - p[0], w.y - p[1])
<< " m at the end, at most " << max_wheels_only_error << " m, heading off by "
<< std::setprecision(2)
<< std::remainder(w.yaw - world.heading(), 2.0 *
PI) * 180.0 /
PI <<
" deg"
<< std::endl;
return completed && n_hits == 0 ? 0 : 1;
}
}
int main(
int argc,
char **argv)
{
try
{
}
catch (const std::exception &e)
{
std::cerr << "Error: " << e.what() << std::endl;
return 1;
}
}
The basic types of bitsim. Code outside this file names Eigen's matrix and vector types only through ...
Follow a dark line with a row of infrared elements.
Definition infrared_line_follower.h:44
Dead reckoning for a differential drive robot from its wheel encoders.
Definition diff_drive_odometry.h:38
The heading of a robot from its gyroscope: dead reckoning of the rate about the vertical.
Definition gyro_heading.h:28
A differential-drive robot in Chrono: a chassis, two driven wheels and a ball caster....
Definition diff_drive_robot.h:52
std::shared_ptr< sensors::InfraredSensor > get_line_sensor() const noexcept
Definition diff_drive_robot.h:290
An image of the floor, centred on the world origin.
Definition downward_camera.h:31
An inertial measurement unit: a three axis accelerometer and a three axis gyroscope,...
Definition imu_sensor.h:32
An array of infrared reflectance elements that looks at the floor, to tell its colour: light paper or...
Definition infrared_sensor.h:33
Class for modelling ultrasonic sensors.
Definition ultrasonic_sensor.h:21
A closed track in the plane: a rectangle centred on the origin with its sides along x and y,...
Definition rounded_rectangle.h:20
Writes the window to dir/frame_00000.png, frame_00001.png, ..., rate times a second of simulation,...
Definition irrlicht_scene.h:121
A camera on a robot whose view is drawn in the top left corner of the window. It only shows the scene...
Definition irrlicht_scene.h:88
A path drawn as a line: in the plane, just above the floor, where a robot has been or where it thinks...
Definition irrlicht_scene.h:48
@ LEFT
Definition diff_drive_robot.h:61
@ RIGHT
Definition diff_drive_robot.h:62
Definition wheel_odometry.cpp:414
void add_to_trails(const Point &truth, const Point &odometry, const Point &wheels_only)
Definition wheel_odometry.cpp:469
Display(World &world, const FloorImage &floor, const std::string &record)
Definition wheel_odometry.cpp:416
bool show(const InfraredSensor &ir, real_t sonar, const GyroHeading &heading, real_t gyro_z, const DiffDriveOdometry &odometry, const DiffDriveOdometry &wheels_only, const Driver &driver, const Command &command, real_t lap)
Definition wheel_odometry.cpp:444
Definition wheel_odometry.cpp:178
Driver(real_t ir_ahead)
Definition wheel_odometry.cpp:190
bool has_given_up() const
Definition wheel_odometry.cpp:248
Command command(const InfraredSensor &ir, real_t sonar, real_t driven, real_t heading, real_t dt)
Definition wheel_odometry.cpp:193
State
Definition wheel_odometry.cpp:181
@ CROSS
Definition wheel_odometry.cpp:185
@ DETOUR
Definition wheel_odometry.cpp:184
@ FOLLOW
Definition wheel_odometry.cpp:182
@ TURN_AWAY
Definition wheel_odometry.cpp:183
@ ALIGN
Definition wheel_odometry.cpp:186
State state() const noexcept
Definition wheel_odometry.cpp:247
bool is_lost() const
Definition wheel_odometry.cpp:249
uint_t n_detours() const noexcept
Definition wheel_odometry.cpp:250
static FloorImage draw(real_t width, real_t height, real_t metres_per_pixel, const std::function< bool(real_t, real_t)> &is_ink, uchar paper=235, uchar ink=25)
Draw a floor: a grey picture of width x height metres of paper, with ink wherever is_ink(x,...
Definition downward_camera.cpp:32
Definition wheel_odometry.cpp:314
bool is_touching_an_obstacle() const
Definition wheel_odometry.cpp:380
CHRONO_DiffDriveRobot & robot()
Definition wheel_odometry.cpp:382
real_t heading() const
Definition wheel_odometry.cpp:379
real_t time() const
Definition wheel_odometry.cpp:377
real_t ir_ahead() const
Definition wheel_odometry.cpp:387
chrono::ChSystemNSC & system()
Definition wheel_odometry.cpp:384
Point position() const
Definition wheel_odometry.cpp:378
World(const FloorImage &floor)
Definition wheel_odometry.cpp:316
void step(const Command &command)
Definition wheel_odometry.cpp:357
void show_floor(const std::string &texture)
Definition wheel_odometry.cpp:370
int main()
Definition discounted_returns.cpp:19
Pieces of an Irrlicht window for a robot simulation: a texture on the floor, a path drawn behind a ro...
const real_t G
Acceleration due to gravity m/secs.
Definition bitsim_consts.h:68
const real_t PI
The PI constant.
Definition bitsim_consts.h:63
const std::string ROBOTS_DIR
Path to robots definitions.
Definition bitsim_consts.h:42
void add_floor_texture(chrono::ChBody &ground, real_t width, real_t height, real_t z, const std::string &texture)
Put a picture on the ground: a rectangle of width x height [m] centred on the origin of the world,...
Definition irrlicht_scene.cpp:22
void irr_draw_line(chrono::irrlicht::ChVisualSystemIrrlicht &vis, const chrono::ChVector3d &start, const chrono::ChVector3d &end, const chrono::ChColor &color, real_t thickness)
Definition irrlicht_utils.cpp:19
void draw_status_bar(chrono::irrlicht::ChVisualSystemIrrlicht &vis, const std::string &text)
Write text on a light bar along the bottom of the window. Call this between Render() and EndScene().
Definition irrlicht_scene.cpp:151
std::size_t uint_t
uint_t
Definition bitsim_types.h:40
double real_t
real_t
Definition bitsim_types.h:20
CartPoleState start()
Definition cart_pole_lqr_mpc.cpp:73
void record(const std::vector< Run > &runs, const std::string &directory)
Definition cart_pole_lqr_mpc.cpp:194
std::map< std::string, std::any > command(real_t v, real_t w)
Definition diff_drive_kinematics.cpp:29
real_t error(const Pose &a, const Pose &b)
Definition ekf_slam.cpp:176
frame(fig)
Definition multi_agent_gif.py:29
End lap(uint_t run)
Definition parallel_monte_carlo.cpp:57
Definition wheel_odometry.cpp:64
const real_t CAMERA_FOV
Definition wheel_odometry.cpp:133
Options parse(int argc, char **argv)
Definition wheel_odometry.cpp:549
const std::string WINDOW_TITLE
Definition wheel_odometry.cpp:85
const std::string ROBOT_FILE
Definition wheel_odometry.cpp:84
const real_t DETOUR_RADIUS
Definition wheel_odometry.cpp:122
const real_t CAMERA_TILT
Definition wheel_odometry.cpp:132
const real_t TRACK_HALF_WIDTH
Definition wheel_odometry.cpp:96
const int CAMERA_WIDTH
Definition wheel_odometry.cpp:134
const real_t TRACK_CORNER_RADIUS
Definition wheel_odometry.cpp:97
const real_t TRACK_HALF_LENGTH
Definition wheel_odometry.cpp:95
const real_t RECORD_RATE
Definition wheel_odometry.cpp:92
const real_t STEP_SIZE
Definition wheel_odometry.cpp:88
const real_t LINE_WIDTH
Definition wheel_odometry.cpp:98
const real_t CRUISE_SPEED
Definition wheel_odometry.cpp:114
std::string to_string(Driver::State state)
Definition wheel_odometry.cpp:276
FloorImage draw_floor()
Definition wheel_odometry.cpp:146
const real_t RENDER_RATE
Definition wheel_odometry.cpp:91
const real_t FLOOR_HEIGHT
Definition wheel_odometry.cpp:100
const chrono::ChVector3d CAMERA_POSITION
Definition wheel_odometry.cpp:131
const uchar INK
Definition wheel_odometry.cpp:103
int run(const Options &options)
Definition wheel_odometry.cpp:588
const real_t PRINT_PERIOD
Definition wheel_odometry.cpp:90
const real_t SEARCH_TURN_RATE
Definition wheel_odometry.cpp:116
const real_t LINE_TURN_RATE
Definition wheel_odometry.cpp:115
const real_t LOST_TIME
Definition wheel_odometry.cpp:117
const Point START
Definition wheel_odometry.cpp:111
const real_t CALIBRATION_TIME
Definition wheel_odometry.cpp:127
const real_t PI
Definition wheel_odometry.cpp:87
std::array< real_t, 2 > Point
Definition wheel_odometry.cpp:82
const real_t STOP_DISTANCE
Definition wheel_odometry.cpp:120
const real_t OBSTACLE_HEIGHT
Definition wheel_odometry.cpp:108
const real_t OBSTACLE_SIZE
Definition wheel_odometry.cpp:107
const real_t TRAIL_STEP
Definition wheel_odometry.cpp:128
const InfraredLineFollower::Parameters FOLLOW_LINE
Definition wheel_odometry.cpp:161
const real_t DETOUR_SPEED
Definition wheel_odometry.cpp:123
const int CAMERA_HEIGHT
Definition wheel_odometry.cpp:135
const real_t METRES_PER_PIXEL
Definition wheel_odometry.cpp:101
const real_t PIVOT_RATE
Definition wheel_odometry.cpp:124
const RoundedRectangle TRACK(TRACK_HALF_LENGTH, TRACK_HALF_WIDTH, TRACK_CORNER_RADIUS)
const real_t TIME_LIMIT
Definition wheel_odometry.cpp:89
bitsim::control::DiffDriveCommand Command
Definition wheel_odometry.cpp:81
const real_t TURN_AWAY_ANGLE
Definition wheel_odometry.cpp:121
const real_t FLOOR_WIDTH
Definition wheel_odometry.cpp:99
const std::vector< Point > OBSTACLES
Definition wheel_odometry.cpp:106
const uchar PAPER
Definition wheel_odometry.cpp:102
What a differential drive robot is told to do: drive at v [m/s] and turn at omega [rad/s],...
Definition infrared_line_follower.h:22
A pose in the plane: the point halfway between the wheels and the heading from the x axis [m,...
Definition diff_drive_odometry.h:45
Definition infrared_line_follower.h:47
Definition wheel_odometry.cpp:542
real_t axle_error
Definition wheel_odometry.cpp:546
bool calibrate
Definition wheel_odometry.cpp:545
bool render
Definition wheel_odometry.cpp:543
std::string record
Definition wheel_odometry.cpp:544