Class o80::Standalone

template<int QUEUE_SIZE, int NB_ACTUATORS, class DRIVER, class o80_STATE, class o80_EXTENDED_STATE>
class o80::Standalone

! A Standalone encapsulates and organize the the communication between a (robot_interfaces) driver, a (robot_interfaces) frontend, a (robot_interfaces) backend and a (o80) backend : at each iteration, information about the current state of the robot actuators are passed by the frontend to the backend, which passes to the driver desired states values.

tparam QUEUE_SIZE

number of commands that can be hosted in the command queue at any point of time. Exceptions will be thrown if more commands are queued.

tparam NB_ACTUATORS

number of actuators of the robot

tparam RI_ACTION

template to the (robot_interfaces) frontend

tparam ROBOT_OUT

template to the (robot_interfaces) frontend

tparam o80_STATE

template to the (o80) BackEnd

tparam EXTENDED_STATE

class encapsulating supplementary arbitrary information (i.e. supplementary to the current actuators state) that will be sent from the (robot_interfaces) frontend to the backend (which will add these information to the observations)

Public Types

typedef std::shared_ptr<DRIVER> DriverPtr
typedef o80_STATE o80State
typedef o80_EXTENDED_STATE o80ExtendedState
typedef DRIVER o80DRIVER

Public Functions

Standalone(DriverPtr driver_ptr, double frequency, std::string segment_id)

Creates instances of:

  • (robot_interfaces) backend

  • (robot interfaces) frontend

  • (o80) BackEnd

Parameters
  • ri_driver – robot_interfaces robot driver

  • frequency – desired frequency

  • segment_id – shared memory segment id for o80 BackEnd.

~Standalone()
void start()

! Starts the robot interfaces backend

void stop()

! Stops the robot interfaces backend

bool spin(bool bursting = false)

! - If bursting is false, performs one iteration and then wait for the time requied to match the desired frequency.

  • If bursting is true, hang until the o80 FrontEnd calls “burst”.

bool spin(o80_EXTENDED_STATE &extended_state, bool bursting = false)

! Similar to spin, and the extended state is added to the observation that is written to the shared memory by the o80 BackEnd.

virtual o80::States<NB_ACTUATORS, o80_STATE> convert(const typename DRIVER::DRIVER_OUT &observation) = 0

! user code to convert the observation read from robot_interfaces frontend into the current o80 States.

virtual DRIVER::DRIVER_IN convert(const o80::States<NB_ACTUATORS, o80_STATE> &states) = 0

! user code to convert the desired states generated by the o80 BackEnd into action required by the robot_interfaces frontend.

inline virtual void enrich_extended_state(o80_EXTENDED_STATE &extended_state, const typename DRIVER::DRIVER_OUT &observation)

! converts the observation as returned by the robot_interfaces frontend into the o80 extended state (optional)

Public Static Attributes

static constexpr int queue_size = QUEUE_SIZE
static constexpr int nb_actuators = NB_ACTUATORS

Private Types

typedef BackEnd<QUEUE_SIZE, NB_ACTUATORS, o80_STATE, o80_EXTENDED_STATE> o80Backend

Private Functions

bool iterate(const TimePoint &time_now, o80_EXTENDED_STATE &extended_state)

Private Members

double frequency_
Microseconds period_
FrequencyManager frequency_manager_
TimePoint now_
std::shared_ptr<Burster> burster_
std::string segment_id_
DriverPtr driver_ptr_
o80Backend o8o_backend_