ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
arpirobot::BaseRobot Class Referenceabstract

#include <arpirobot/core/robot/BaseRobot.hpp>

Public Member Functions

 BaseRobot (const BaseRobot &other)=delete
 
BaseRobotoperator= (const BaseRobot &other)=delete
 
void feedWatchdog ()
 
void start ()
 
virtual void robotStarted ()=0
 
virtual void robotEnabled ()=0
 
virtual void robotDisabled ()=0
 
virtual void enabledPeriodic ()=0
 
virtual void disabledPeriodic ()=0
 
virtual void periodic ()=0
 

Static Public Member Functions

static std::shared_ptr< TaskscheduleRepeatedFunction (const std::function< void()> &&func, sched_clk::duration rate)
 
static void runOnceSoon (const std::function< void()> &&func)
 
static void removeTaskFromScheduler (std::shared_ptr< Task > task)
 
static void beginWhenReady (BaseDevice *device)
 
static void deviceDestroyed (BaseDevice *device)
 

Static Public Attributes

static bool exists
 

Detailed Description

Base class to facilitate general robot code structure/flow Each robot program should have a single class that inherits from this class and implements the pure virtual functions.

Member Function Documentation

◆ beginWhenReady()

static void arpirobot::BaseRobot::beginWhenReady ( BaseDevice device)
static

Initialize a device to run once the robot is started. If this is called before a robot is started this will not run the device's BaseDevice::begin immediately, but when BaseRobot::start() is called. If the robot is already started, BaseDevice::begin will be called.

Parameters
deviceThe device to begin once the robot is instantiated

◆ deviceDestroyed()

static void arpirobot::BaseRobot::deviceDestroyed ( BaseDevice device)
static

Run when a device is destructed. Removes device from managed list.

◆ disabledPeriodic()

virtual void arpirobot::BaseRobot::disabledPeriodic ( )
pure virtual

Run periodically while the robot is disabled

◆ enabledPeriodic()

virtual void arpirobot::BaseRobot::enabledPeriodic ( )
pure virtual

Run periodically while the robot is enabled

◆ feedWatchdog()

void arpirobot::BaseRobot::feedWatchdog ( )

Feed the watchdog so devices don't become disabled

◆ periodic()

virtual void arpirobot::BaseRobot::periodic ( )
pure virtual

Run periodically regardless of robot state

◆ removeTaskFromScheduler()

static void arpirobot::BaseRobot::removeTaskFromScheduler ( std::shared_ptr< Task task)
static

Remove the given task (repeated task) from the scheduler

Parameters
taskThe task to remove

◆ robotDisabled()

virtual void arpirobot::BaseRobot::robotDisabled ( )
pure virtual

Run each time the robot is disabled

◆ robotEnabled()

virtual void arpirobot::BaseRobot::robotEnabled ( )
pure virtual

Run each time the robot is enabled

◆ robotStarted()

virtual void arpirobot::BaseRobot::robotStarted ( )
pure virtual

Run once when the robot is started

◆ runOnceSoon()

static void arpirobot::BaseRobot::runOnceSoon ( const std::function< void()> &&  func)
static

Run a function on the scheduler as soon as possible (no delay). The given function will only run once This method will return immediately (will not wait for the target function to run)

Parameters
funcThe function to run

◆ scheduleRepeatedFunction()

static std::shared_ptr<Task> arpirobot::BaseRobot::scheduleRepeatedFunction ( const std::function< void()> &&  func,
sched_clk::duration  rate 
)
static

Schedule a function to be run at a given rate.

Parameters
funcThe function to run
rateThe rate to run at
Returns
The task on the scheduler. Can be used to stop the task later

◆ start()

void arpirobot::BaseRobot::start ( )

Start the robot. Only one robot instance my run at a time


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