bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
mcts_line_following.cpp File Reference
#include "bitrl/base/bitrl_types.h"
#include "bitrl/rl/algorithms/mc/mc_tree_search_solver.h"
#include "bitsim/bitsim_config.h"
#include "bitsim/bitsim_consts.h"
#include "bitsim/control/infrared_line_follower.h"
#include "bitsim/rigid_bodies/chrono_robots/contact_counter.h"
#include "bitsim/rigid_bodies/chrono_robots/diff_drive_robot.h"
#include "bitsim/sensors/downward_camera.h"
#include "bitsim/trajectory/rounded_rectangle.h"
#include "bitsim/utils/render/irrlicht_scene.h"
#include "bitsim/utils/render/irrlicht_utils.h"
#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 <limits>
#include <memory>
#include <optional>
#include <random>
#include <sstream>
#include <stdexcept>
#include <string>
#include <thread>
#include <vector>
Include dependency graph for mcts_line_following.cpp:

Classes

struct  mcts_line_following::Pose
class  mcts_line_following::TrackModel
struct  mcts_line_following::TrackModel::TimeStep
struct  mcts_line_following::TowardsTheLine
struct  mcts_line_following::Candidate
class  mcts_line_following::World
class  mcts_line_following::Display
struct  mcts_line_following::Options
struct  mcts_line_following::MCTSConfig
 The configuration of MCTSSolver. More...
class  mcts_line_following::MCTSSolver< EnvTp, RolloutPolicy >
 Monte Carlo tree search, with UCB to pick the children (UCT). More...
class  mcts_line_following::CHRONO_DiffDriveRobot
 A differential-drive robot in Chrono: a chassis, two driven wheels and a ball caster. Each driven wheel has an actuators::DCMotor. More...
class  mcts_line_following::ContactCounter
 Counts the contacts that touch any of a set of bodies, such as the obstacles a robot should not hit. More...
class  mcts_line_following::FloorImage
 An image of the floor, centred on the world origin. More...
class  mcts_line_following::RoundedRectangle
 A closed track in the plane: a rectangle centred on the origin with its sides along x and y, and its corners rounded with quarter circles. More...
class  mcts_line_following::FrameRecorder
 Writes the window to dir/frame_00000.png, frame_00001.png, ..., rate times a second of simulation, to be put together into a movie. With an empty dir it writes nothing. More...
class  mcts_line_following::Trail
 A path drawn as a line: in the plane, just above the floor, where a robot has been or where it thinks it has been; or in space, where something has flown. More...

Namespaces

namespace  mcts_line_following

Typedefs

using mcts_line_following::Command = bitsim::control::DiffDriveCommand
using mcts_line_following::Point = std::array<real_t, 2>
using mcts_line_following::real_t
 real_t
using mcts_line_following::uint_t
 uint_t

Functions

real_t mcts_line_following::angle_around_track (real_t x, real_t y)
real_t mcts_line_following::distance_to_box (const Point &box, real_t x, real_t y)
real_t mcts_line_following::track_direction (real_t x, real_t y)
template<typename Solver>
std::vector< Candidate > mcts_line_following::candidates (const Solver &solver, const TrackModel &model)
FloorImage mcts_line_following::draw_floor ()
Options mcts_line_following::parse (int argc, char **argv)
int mcts_line_following::run (const Options &options)
int main (int argc, char **argv)

Variables

const std::string mcts_line_following::WINDOW_TITLE = "Line following with Monte Carlo tree search"
const real_t mcts_line_following::PI = bitsim::consts::maths::PI
const real_t mcts_line_following::STEP_SIZE = 0.01
const real_t mcts_line_following::DECISION_PERIOD = 0.2
const real_t mcts_line_following::TIME_LIMIT = 150.0
const real_t mcts_line_following::PRINT_PERIOD = 2.0
const real_t mcts_line_following::RENDER_RATE = 30.0
const real_t mcts_line_following::RECORD_RATE = 10.0
const real_t mcts_line_following::FOLLOW_BEHIND = 2.6
const real_t mcts_line_following::FOLLOW_HEIGHT = 2.4
const real_t mcts_line_following::FOLLOW_AHEAD = 1.5
const real_t mcts_line_following::TRACK_HALF_LENGTH = 2.2
const real_t mcts_line_following::TRACK_HALF_WIDTH = 1.4
const real_t mcts_line_following::TRACK_CORNER_RADIUS = 0.7
const real_t mcts_line_following::LINE_WIDTH = 0.05
const real_t mcts_line_following::FLOOR_WIDTH = 5.6
const real_t mcts_line_following::FLOOR_HEIGHT = 4.6
const real_t mcts_line_following::METRES_PER_PIXEL = 0.005
const std::vector< Point > mcts_line_following::OBSTACLES {{0.0, -TRACK_HALF_WIDTH}, {-0.2, TRACK_HALF_WIDTH}}
const real_t mcts_line_following::OBSTACLE_SIZE = 0.3
const real_t mcts_line_following::OBSTACLE_HEIGHT = 0.4
const Point mcts_line_following::START {-1.3, -TRACK_HALF_WIDTH}
const RoundedRectangle mcts_line_following::TRACK (TRACK_HALF_LENGTH, TRACK_HALF_WIDTH, TRACK_CORNER_RADIUS)
const real_t mcts_line_following::CHASSIS_AHEAD = 0.1
const real_t mcts_line_following::ROBOT_RADIUS = 0.3
const real_t mcts_line_following::CLEARANCE = 0.05
const uint_t mcts_line_following::MODEL_SUBSTEPS = 4
const std::array< Command, 5 > mcts_line_following::COMMANDS
const real_t mcts_line_following::LINE_COST = 0.5
const real_t mcts_line_following::HIT_COST = 10.0
const real_t mcts_line_following::ROLLOUT_GAIN = 2.0
const real_t mcts_line_following::ROLLOUT_APPROACH = 2.0
const real_t mcts_line_following::ROLLOUT_RANDOM = 0.2
const real_t mcts_line_following::DETOUR_NEAR = 1.0
const real_t mcts_line_following::DETOUR_OFFSET = 0.6
const MCTSConfig mcts_line_following::SEARCH
const real_t mcts_line_following::METRES_PER_RADIAN = TRACK.perimeter() / (2.0 * PI)
const std::array< const char *, 5 > mcts_line_following::COMMAND_NAMES

Function Documentation

◆ main()

int main ( int argc,
char ** argv )