upkie 9.0.0
Open-source wheeled biped robots
|
Loop transmitting actions to the actuation and observations to the agent. More...
#include <Spine.h>
Classes | |
struct | Parameters |
Spine parameters. More... | |
Public Member Functions | |
Spine (const Parameters ¶ms, interfaces::Interface &interface, SensorPipeline &sensors, ObserverPipeline &observers, ControllerPipeline &controllers) | |
Initialize spine. More... | |
void | reset (const palimpsest::Dictionary &config) |
Reset the spine with a new configuration. More... | |
void | run () |
Run the spine loop until termination. More... | |
void | cycle () |
Spin one cycle of the spine loop. | |
void | simulate (unsigned nb_substeps) |
Alternative to run where the actuation interface is cycled a fixed number of times, and communication cycles are not frequency-regulated. More... | |
void | cycle_actuation () |
Spin one cycle of communications with the actuation interface. More... | |
Protected Attributes | |
const unsigned | frequency_ |
Frequency of the spine loop in [Hz]. | |
interfaces::Interface & | actuation_ |
Interface that communicates with actuators. More... | |
AgentInterface | agent_interface_ |
Shared memory mapping for inter-process communication. | |
std::future< Output > | actuation_output_ |
Future used to wait for moteus replies. | |
std::vector< ServoReply > | servo_replies_ |
Latest servo replies. They are copied and thread-safe. | |
palimpsest::Dictionary | working_dict_ |
All data from observation to action goes to this dictionary. | |
SensorPipeline | sensors_ |
Pipeline of sensors, executed in that order. | |
ObserverPipeline | observers_ |
Pipeline of observers, executed in that order. | |
mpacklog::Logger | logger_ |
Logger for the working_dict_ produced at each cycle. | |
std::vector< char > | ipc_buffer_ |
Buffer used to serialize/deserialize dictionaries in IPC. | |
const bool & | caught_interrupt_ |
Boolean flag that becomes true when an interruption is caught. | |
StateMachine | state_machine_ |
Internal state machine. | |
State | state_cycle_beginning_ |
State after the last Event::kCycleBeginning. | |
State | state_cycle_end_ |
State after the last Event::kCycleEnd. | |
size_t | rx_count_ |
Number of actuation replies received during the latest cycle. | |
ControllerPipeline | controllers_ |
Pipeline of controllers, executed in that order. | |
Loop transmitting actions to the actuation and observations to the agent.
The spine acts as the intermediary between the actuation interface (e.g. moteus servos connected to the CAN-FD bus) and an agent communicating over shared memory (the agent interface). It packs observations to the agent from actuation replies and commands to the actuation from agent actions.
The spine processes requests at the beginning and end of each control cycle according to its StateMachine. The overall specification of the state machine is summarized in the following diagram:
See StateMachine for more details.