bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
pi_camera_line_following.cpp File Reference
#include "bitsim/bitsim_config.h"
#include "bitsim/bitsim_consts.h"
#include "bitsim/bitsim_types.h"
#include "bitsim/rigid_bodies/chrono_robots/diff_drive_robot.h"
#include "bitsim/sensors/backends/mjpeg_http_camera_backend.h"
#include "bitsim/sensors/downward_camera.h"
#include "bitsim/utils/timing.h"
#include <chrono/physics/ChBodyEasy.h>
#include <chrono/physics/ChContactMaterialNSC.h>
#include <chrono/physics/ChSystemNSC.h>
#include <opencv2/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/videoio.hpp>
#include <algorithm>
#include <array>
#include <chrono>
#include <cmath>
#include <cstdlib>
#include <filesystem>
#include <iomanip>
#include <iostream>
#include <limits>
#include <optional>
#include <sstream>
#include <stdexcept>
#include <string>
#include <thread>
#include <vector>
Include dependency graph for pi_camera_line_following.cpp:

Classes

struct  pi_camera_line_following::LineReading
struct  pi_camera_line_following::Segment
struct  pi_camera_line_following::Path
struct  pi_camera_line_following::Start
struct  pi_camera_line_following::Command
class  pi_camera_line_following::LineFollower
class  pi_camera_line_following::SquarePathDriver
class  pi_camera_line_following::World
class  pi_camera_line_following::Display
struct  pi_camera_line_following::Options
class  pi_camera_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  pi_camera_line_following::DownwardCamera
 A camera on a robot that looks straight down at the floor ahead. More...
class  pi_camera_line_following::FloorImage
 An image of the floor, centred on the world origin. More...
struct  pi_camera_line_following::CameraFrame
 A frame delivered by a camera backend. More...
class  pi_camera_line_following::MJPEG_HTTPCameraBackend
 Receives the frames of an MJPEG stream over HTTP, the multipart/x-mixed-replace response that many cameras and camera servers give, for example example 31's FastAPI server on a Raspberry Pi. More...

Namespaces

namespace  pi_camera_line_following

Typedefs

using pi_camera_line_following::Point = std::array<real_t, 2>
using pi_camera_line_following::real_t
 real_t
using pi_camera_line_following::uint_t
 uint_t

Functions

cv::Mat pi_camera_line_following::to_gray (const cv::Mat &image)
cv::Mat pi_camera_line_following::dark_pixels (const cv::Mat &gray)
LineReading pi_camera_line_following::read_line (const cv::Mat &view, const DownwardCamera &camera)
std::optional< Path > pi_camera_line_following::find_square (const FloorImage &floor)
std::optional< std::pair< Segment, real_t > > pi_camera_line_following::find_segment (const FloorImage &floor)
real_t pi_camera_line_following::nearest_side_heading (const Path &path, const Point &p)
Start pi_camera_line_following::start_on_square (const Path &square)
Segment pi_camera_line_following::counterclockwise (const Segment &side, const Point &centre)
Start pi_camera_line_following::start_on_side (const Segment &side)
Options pi_camera_line_following::parse (int argc, char **argv)
std::optional< std::pair< Segment, real_t > > pi_camera_line_following::wait_for_next_side (const MJPEG_HTTPCameraBackend &stream, real_t floor_width, real_t timeout)
int pi_camera_line_following::run (const Options &options)
int main (int argc, char **argv)
real_t pi_camera_line_following::milliseconds_since (WallClock::time_point t)
 The milliseconds since a time point.

Variables

const std::string pi_camera_line_following::DEFAULT_SERVER = "http://alex-rpi-5.local:8000"
const std::string pi_camera_line_following::SQUARE_PATH_ENDPOINT = "/odysseus/camera/square-path"
const std::string pi_camera_line_following::CAMERA_ENDPOINT = "/odysseus/camera"
const std::string pi_camera_line_following::ROBOT_FILE = bitsim::consts::ROBOTS_DIR + "/bitsim_diff_drive_robot.json"
const std::string pi_camera_line_following::WINDOW_TITLE = "A line following robot with a Raspberry Pi camera"
const real_t pi_camera_line_following::PI = bitsim::consts::maths::PI
const real_t pi_camera_line_following::STEP_SIZE = 0.01
const real_t pi_camera_line_following::DEFAULT_FLOOR_WIDTH = 3.0
const real_t pi_camera_line_following::TIME_LIMIT = 120.0
const real_t pi_camera_line_following::PRINT_PERIOD = 1.0
const real_t pi_camera_line_following::CRUISE_SPEED = 0.25
const real_t pi_camera_line_following::MIN_SPEED_RATIO = 0.3
const real_t pi_camera_line_following::MAX_TURN_RATE = 1.5
const real_t pi_camera_line_following::SEARCH_TURN_RATE = 0.6
const real_t pi_camera_line_following::LOST_TIME = 5.0
const real_t pi_camera_line_following::WAIT_TIME = 15.0
const real_t pi_camera_line_following::MIN_LINE_COVERAGE = 0.01
const real_t pi_camera_line_following::SQUARE_PATH_SPEED = 0.35
const real_t pi_camera_line_following::CORNER_TURN_RATE = 1.5
const real_t pi_camera_line_following::STOP_GAIN = 2.0
const real_t pi_camera_line_following::DARK_RATIO = 0.6

Function Documentation

◆ main()

int main ( int argc,
char ** argv )