bitsim
Model, simulate, estimate and control robots in C++
Loading...
Searching...
No Matches
pi_camera_line_following::DownwardCamera Class Reference

A camera on a robot that looks straight down at the floor ahead. More...

#include <downward_camera.h>

Classes

struct  Config
 The camera's mounting and image. More...

Public Member Functions

 DownwardCamera ()
 A camera with the default Config.
 DownwardCamera (const Config &config)
const Config & config () const noexcept
cv::Mat view (const FloorImage &floor, real_t x, real_t y, real_t yaw) const
 What the camera sees with the robot at (x, y) heading yaw.
std::array< real_t, 2 > to_robot (real_t column, real_t row) const
 Where a pixel of the camera's image is relative to the robot.
std::vector< std::array< real_t, 2 > > line_points (const cv::Mat &view, uint_t n_bands=4, real_t dark_ratio=0.6, real_t min_share=0.02) const
 Where a dark line crosses the camera's image: the image is cut into n_bands bands across the robot's heading, and for each band with enough dark pixels in it, the middle of them, relative to the robot [m], forward and to its left, as to_robot gives them.
std::array< std::array< real_t, 2 >, 4 > footprint (real_t x, real_t y, real_t yaw) const
 The corners of the floor the camera sees, in world coordinates: far left, far right, near right, near left.

Detailed Description

A camera on a robot that looks straight down at the floor ahead.

The camera sees a rectangle of the floor centred offset metres ahead of the robot's reference point, usually the centre of its axle. The rows of its image run from the far edge of that rectangle, row 0, to the near edge, and the columns from the robot's left, column 0, to its right, as a camera that faces forward and tilts down would show them.

Constructor & Destructor Documentation

◆ DownwardCamera() [1/2]

◆ DownwardCamera() [2/2]

Member Function Documentation

◆ config()

const Config & bitsim::sensors::DownwardCamera::config ( ) const
inlinenoexcept

◆ footprint()

std::array< std::array< real_t, 2 >, 4 > bitsim::sensors::DownwardCamera::footprint ( real_t x,
real_t y,
real_t yaw ) const

The corners of the floor the camera sees, in world coordinates: far left, far right, near right, near left.

◆ line_points()

std::vector< std::array< real_t, 2 > > bitsim::sensors::DownwardCamera::line_points ( const cv::Mat & view,
uint_t n_bands = 4,
real_t dark_ratio = 0.6,
real_t min_share = 0.02 ) const

Where a dark line crosses the camera's image: the image is cut into n_bands bands across the robot's heading, and for each band with enough dark pixels in it, the middle of them, relative to the robot [m], forward and to its left, as to_robot gives them.

Parameters
viewWhat the camera sees, grey or BGR
n_bandsHow many bands to cut the image into, along the heading
dark_ratioA pixel darker than this share of the brightest pixel is line
min_shareA band needs this share of its pixels dark to count

◆ to_robot()

std::array< real_t, 2 > bitsim::sensors::DownwardCamera::to_robot ( real_t column,
real_t row ) const

Where a pixel of the camera's image is relative to the robot.

Returns
{forward, left}: metres ahead of the reference point and metres to its left

◆ view()

cv::Mat bitsim::sensors::DownwardCamera::view ( const FloorImage & floor,
real_t x,
real_t y,
real_t yaw ) const

What the camera sees with the robot at (x, y) heading yaw.

Floor outside the image is white


The documentation for this class was generated from the following files: