MRMS
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Robot Class Referenceabstract

#include <mrm-robot.h>

Inheritance diagram for Robot:
RobotLine RobotMaze RobotMin RobotSoccer RobotLineTest

Public Member Functions

 Robot (char name[15]=(char *)"MRMS robot", char ssid[15]=(char *)"MRMS", char wiFiPassword[15]=(char *)"mrms")
 
void actionAdd (ActionBase *action)
 
void actionEnd ()
 
bool actionPreprocessing (bool andFinish=true)
 
void actionPreprocessingEnd ()
 
void add (Board *aBoard)
 
virtual void bitmapsSet ()=0
 
void blink ()
 
void bluetoothTest ()
 
void end ()
 
void canBusSniffToggle ()
 
void canIdChange ()
 
void colorIlluminationOff ()
 
void colorIlluminationOn ()
 
void colorPatternErase ()
 
void colorPatternPrint ()
 
void colorPatternRecognize ()
 
void colorPatternRecord ()
 
void delayMs (uint16_t pauseMs)
 
void delayMicros (uint16_t pauseMicros)
 
uint8_t devicesScan (bool verbose)
 
void devicesStart (uint8_t measuringMode=0)
 
void devicesStop ()
 
void errors ()
 
void firmwarePrint ()
 
float fpsGet ()
 
void fpsPrint ()
 
virtual void goAhead ()=0
 
void i2cTest ()
 
void info ()
 
void irFinder3Test ()
 
void irFinder3TestCalculated ()
 
void lidar2mTest ()
 
void lidar4mTest ()
 
void lidarCalibrate ()
 
virtual void loop ()=0
 
void menu ()
 
void menuColor ()
 
void menuMainAndIdle ()
 
void menuReflectance ()
 
void menuSystem ()
 
void messagePrint (CANBusMessage *msg, bool outbound)
 
void messagesReceive ()
 
void motorTest ()
 
void nodeTest ()
 
void noLoopWithoutThis ()
 
void oscillatorTest ()
 
void reflectanceArrayCalibrationPrint ()
 
void run ()
 
uint16_t serialReadNumber (uint16_t timeoutFirst=3000, uint16_t timeoutBetween=500, bool onlySingleDigitInput=false, uint16_t limit=0xFFFE, bool printWarnings=true)
 
void servoInteractive ()
 
bool setup (bool andFinish=true)
 
bool sniffing ()
 
void stopAll ()
 
bool stressTest ()
 
void thermoTest ()
 
bool userBreak ()
 
void verboseToggle ()
 

Public Attributes

Mrm_can_bus * mrm_can_bus
 
Mrm_8x8a * mrm_8x8a
 
Mrm_bldc2x50 * mrm_bldc2x50
 
Mrm_bldc4x2_5 * mrm_bldc4x2_5
 
Mrm_col_b * mrm_col_b
 
Mrm_col_can * mrm_col_can
 
Mrm_fet_can * mrm_fet_can
 
Mrm_imu * mrm_imu
 
Mrm_ir_finder3 * mrm_ir_finder3
 
Mrm_lid_can_b * mrm_lid_can_b
 
Mrm_lid_can_b2 * mrm_lid_can_b2
 
Mrm_mot2x50 * mrm_mot2x50
 
Mrm_mot4x3_6can * mrm_mot4x3_6can
 
Mrm_mot4x10 * mrm_mot4x10
 
Mrm_node * mrm_node
 
Mrm_ref_can * mrm_ref_can
 
Mrm_servo * mrm_servo
 
Mrm_switch * mrm_switch
 
Mrm_therm_b_can * mrm_therm_b_can
 
Mrm_us_b * mrm_us_b
 
Mrm_us1 * mrm_us1
 

Protected Member Functions

void actionProcess ()
 
void actionSet ()
 
void actionSet (ActionBase *newAction)
 
uint8_t boardsDisplayAll ()
 
bool boardDisplayAndSelect (uint8_t *selectedBoardIndex, uint8_t *selectedDeviceIndex, uint8_t *maxInput, uint8_t *lastBoardAndIndex)
 
bool boardSelect (uint8_t selectedNumber, uint8_t *selectedBoardIndex, uint8_t *selectedDeviceIndex, uint8_t *maxInput)
 
void fpsPause ()
 
void fpsUpdate ()
 
void fpsReset ()
 
void verbosePrint ()
 
void vprint (const char *fmt, va_list argp)
 

Protected Attributes

ActionBase * _action [ACTIONS_LIMIT]
 
uint8_t _actionNextFree = 0
 
ActionBase * _actionCANBusStress
 
ActionBase * _actionCurrent
 
ActionBase * _actionDoNothing
 
ActionBase * _actionLoop
 
ActionBase * _actionMenuMain
 
ActionBase * _actionPrevious
 
ActionBase * _actionStop
 
Board * board [BOARDS_LIMIT]
 
uint8_t _boardNextFree = 0
 
uint8_t _devicesAtStartup = 0
 
bool _devicesScanBeforeMenu = true
 
uint32_t fpsMs [2] = { 0, 0 }
 
uint8_t fpsNextIndex = 0
 
uint32_t fpsTopGap = 0
 
uint8_t menuLevel = 1
 
CANBusMessage * _msg
 
char _name [16]
 
bool _sniff = false
 
char _ssid [16]
 
bool verbose = false
 
char _wiFiPassword [16]
 

Detailed Description

Base class for all robots.

Member Function Documentation

◆ actionAdd()

void Robot::actionAdd ( ActionBase *  action)

Add a new action to the collection of robot's possible actions.

Parameters
action- the new action.

◆ actionEnd()

void Robot::actionEnd ( )
inline

End current action

◆ actionPreprocessing()

bool Robot::actionPreprocessing ( bool  andFinish = true)

Is this current action's initialization

Parameters
andFinish- finish initialization
Returns
- it is.

◆ actionPreprocessingEnd()

void Robot::actionPreprocessingEnd ( )
inline

Finish action's intialization phase

◆ actionProcess()

void Robot::actionProcess ( )
protected

Actually perform the action

◆ actionSet() [1/2]

void Robot::actionSet ( )
protected

User sets a new action, using keyboard or Bluetooth

◆ actionSet() [2/2]

void Robot::actionSet ( ActionBase *  newAction)
protected

New action is set in the program

Parameters
newAction- the new action.

◆ add()

void Robot::add ( Board *  aBoard)

Add a new board to the collection of possible boards for the robot

Parameters
aBoard- the board.

◆ bitmapsSet()

virtual void Robot::bitmapsSet ( )
pure virtual

Store bitmaps in mrm-led8x8a.

Implemented in RobotSoccer, RobotMin, RobotMaze, and RobotLine.

◆ blink()

void Robot::blink ( )

Blink LED

◆ bluetoothTest()

void Robot::bluetoothTest ( )

Test Bluetooth

◆ boardDisplayAndSelect()

bool Robot::boardDisplayAndSelect ( uint8_t *  selectedBoardIndex,
uint8_t *  selectedDeviceIndex,
uint8_t *  maxInput,
uint8_t *  lastBoardAndIndex 
)
protected

Finds board and device's index. Similar to next function, but display choices, too.

Parameters
selectedBoardIndex- output
selectedDeviceIndex- otuput
maxInput- output
lastBoardAndIndex- output
Returns
- true if found

◆ boardsDisplayAll()

uint8_t Robot::boardsDisplayAll ( )
protected

Displays all boards

Returns
- last board and device's index, 0 if none

◆ boardSelect()

bool Robot::boardSelect ( uint8_t  selectedNumber,
uint8_t *  selectedBoardIndex,
uint8_t *  selectedDeviceIndex,
uint8_t *  maxInput 
)
protected

Finds board and device's index for a number received from boardsDisplayAll(). Similar to previous function, but no display.

Parameters
selectedNumber- input
selectedBoardIndex- output, NULL if none found
selectedDeviceIndex- otuput
maxInput- output
Returns
- true if found

Finds board and device's index for a number received from boardsDisplayAll()

Parameters
selectedNumber- input
selectedBoardIndex- output
selectedDeviceIndex- otuput
maxInput- output
Returns
- true if found

◆ canBusSniffToggle()

void Robot::canBusSniffToggle ( )

Display all the incomming and outcomming CAN Bus messages

◆ canIdChange()

void Robot::canIdChange ( )

Change device's id

◆ colorIlluminationOff()

void Robot::colorIlluminationOff ( )

mrm-color-can illumination off

◆ colorIlluminationOn()

void Robot::colorIlluminationOn ( )

mrm-color-can illumination on

◆ colorPatternErase()

void Robot::colorPatternErase ( )

Erase HSV patterns

◆ colorPatternPrint()

void Robot::colorPatternPrint ( )

Print HSV patterns

◆ colorPatternRecognize()

void Robot::colorPatternRecognize ( )

Recognize HSV color pattern

◆ colorPatternRecord()

void Robot::colorPatternRecord ( )

Record HSV color patterns

◆ delayMicros()

void Robot::delayMicros ( uint16_t  pauseMicros)

The right way to use Arduino function delayMicros

Parameters
pauseMicros- pause in micros. One run even if pauseMicros == 0, so that delayMicross(0) receives all messages.

◆ delayMs()

void Robot::delayMs ( uint16_t  pauseMs)

The right way to use Arduino function delay

Parameters
pauseMs- pause in ms. One run even if pauseMs == 0, so that delayMs(0) receives all messages.

◆ devicesScan()

uint8_t Robot::devicesScan ( bool  verbose)

Contacts all the CAN Bus devices and checks which one is alive. @verbose - if true, print.

Returns
count

◆ devicesStart()

void Robot::devicesStart ( uint8_t  measuringMode = 0)

Starts devices' CAN Bus messages broadcasting.

◆ devicesStop()

void Robot::devicesStop ( )

Stops broadcasting of CAN Bus messages

◆ end()

void Robot::end ( )
inline

End current action

◆ errors()

void Robot::errors ( )

Displays errors and stops motors, if any.

◆ firmwarePrint()

void Robot::firmwarePrint ( )

Displays each CAN Bus device's firmware

◆ fpsGet()

float Robot::fpsGet ( )

Returns FPS (frames per second).

Returns
- FPS

◆ fpsPause()

void Robot::fpsPause ( )
protected

Avoids FPS measuring in the next 2 cycles.

◆ fpsPrint()

void Robot::fpsPrint ( )

Prints FPS all CAN Bus devices and mrm-eps32 boards. Also prints CAN Bus frequency.

◆ fpsReset()

void Robot::fpsReset ( )
protected

Resets FPS data

◆ fpsUpdate()

void Robot::fpsUpdate ( )
protected

Updates data for FPS calculation

◆ goAhead()

virtual void Robot::goAhead ( )
pure virtual

Orders the robot to go ahead

Implemented in RobotSoccer, RobotMin, RobotMaze, and RobotLine.

◆ i2cTest()

void Robot::i2cTest ( )

Lists I2C devices

◆ info()

void Robot::info ( )

Request information

◆ irFinder3Test()

void Robot::irFinder3Test ( )

Tests mrm-ir-finder3, raw data.

◆ irFinder3TestCalculated()

void Robot::irFinder3TestCalculated ( )

Tests mrm-ir-finder3, calculated data.

◆ lidar2mTest()

void Robot::lidar2mTest ( )

Tests mrm-lid-can-b

◆ lidar4mTest()

void Robot::lidar4mTest ( )

Tests mrm-lid-can-b2

◆ lidarCalibrate()

void Robot::lidarCalibrate ( )

Calibrates lidars

◆ loop()

virtual void Robot::loop ( )
pure virtual

User test, defined in derived classes.

Implemented in RobotSoccer, RobotMin, RobotMaze, and RobotLine.

◆ menu()

void Robot::menu ( )

Displays menu

◆ menuColor()

void Robot::menuColor ( )

Color menu

◆ menuMainAndIdle()

void Robot::menuMainAndIdle ( )

Displays menu and stops motors

◆ menuReflectance()

void Robot::menuReflectance ( )

Reflectance menu

◆ menuSystem()

void Robot::menuSystem ( )

System menu

◆ messagePrint()

void Robot::messagePrint ( CANBusMessage *  msg,
bool  outbound 
)

Print CAN Bus message

Parameters
msg- message
oubound- if not, inbound

◆ messagesReceive()

void Robot::messagesReceive ( )

Receives CAN Bus messages.

◆ motorTest()

void Robot::motorTest ( )

Tests motors

◆ nodeTest()

void Robot::nodeTest ( )

Tests mrm-node

◆ noLoopWithoutThis()

void Robot::noLoopWithoutThis ( )

Any for or while loop must include call to this function.

◆ oscillatorTest()

void Robot::oscillatorTest ( )

Production test

◆ reflectanceArrayCalibrationPrint()

void Robot::reflectanceArrayCalibrationPrint ( )

Prints mrm-ref-can* calibration data

◆ run()

void Robot::run ( )

Starts robot's program

◆ serialReadNumber()

uint16_t Robot::serialReadNumber ( uint16_t  timeoutFirst = 3000,
uint16_t  timeoutBetween = 500,
bool  onlySingleDigitInput = false,
uint16_t  limit = 0xFFFE,
bool  printWarnings = true 
)

Reads serial ASCII input and converts it into an integer

Parameters
timeoutFirst- timeout for first input
timeoutBetween- timeout between inputs
onlySingleDigitInput- completes input after first digit
limit- returns 0xFFFF if overstepped
printWarnings- prints out of range or timeout warnings
Returns
- converted number or 0xFFFF when timeout

◆ servoInteractive()

void Robot::servoInteractive ( )

Moves servo motor manually

◆ setup()

bool Robot::setup ( bool  andFinish = true)
inline

Shorthand for actionPreprocessing(). Checks if this is first run.

Parameters
andFinish- finish initialization
Returns
- first run or not.

◆ sniffing()

bool Robot::sniffing ( )
inline

Checks if sniffing is active

Returns
- active or not

◆ stopAll()

void Robot::stopAll ( )

Stops all motors

◆ stressTest()

bool Robot::stressTest ( )

CAN Bus stress test

◆ thermoTest()

void Robot::thermoTest ( )

Tests mrm-therm-b-can

◆ userBreak()

bool Robot::userBreak ( )

Checks if user tries to break the program

Returns
- true if break requested.

◆ verbosePrint()

void Robot::verbosePrint ( )
protected

Prints additional data in every loop pass

◆ verboseToggle()

void Robot::verboseToggle ( )

Verbose output toggle

◆ vprint()

void Robot::vprint ( const char *  fmt,
va_list  argp 
)
protected

Print to all serial ports, pointer to list


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