vulp
2.3.0
|
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, actuation::Interface &interface, observation::ObserverPipeline &observers) | |
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. More... | |
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... | |
Protected Attributes | |
const unsigned | frequency_ |
Frequency of the spine loop in [Hz]. More... | |
actuation::Interface & | actuation_ |
Interface that communicates with actuators. More... | |
AgentInterface | agent_interface_ |
Shared memory mapping for inter-process communication. More... | |
std::future< actuation::moteus::Output > | actuation_output_ |
Future used to wait for moteus replies. More... | |
std::vector< actuation::moteus::ServoReply > | latest_replies_ |
Latest servo replies. They are copied and thread-safe. More... | |
palimpsest::Dictionary | working_dict_ |
All data from observation to action goes to this dictionary. More... | |
observation::ObserverPipeline | observer_pipeline_ |
Pipeline of observers, executed in that order. More... | |
mpacklog::Logger | logger_ |
Logger for the working_dict_ produced at each cycle. More... | |
std::vector< char > | ipc_buffer_ |
Buffer used to serialize/deserialize dictionaries in IPC. More... | |
const bool & | caught_interrupt_ |
Boolean flag that becomes true when an interruption is caught. More... | |
StateMachine | state_machine_ |
Internal state machine. More... | |
State | state_cycle_beginning_ |
State after the last Event::kCycleBeginning. More... | |
State | state_cycle_end_ |
State after the last Event::kCycleEnd. More... | |
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.
vulp.spine::Spine::Spine | ( | const Parameters & | params, |
actuation::Interface & | interface, | ||
observation::ObserverPipeline & | observers | ||
) |
void vulp.spine::Spine::cycle | ( | ) |
void vulp.spine::Spine::reset | ( | const palimpsest::Dictionary & | config | ) |
void vulp.spine::Spine::run | ( | ) |
Run the spine loop until termination.
Each iteration of the loop runs observers, computes the action and cycles the actuation interface. Additionally, this function collects debug values and logs everything.
void vulp.spine::Spine::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.
[in] | nb_substeps | Number of actuation cycles per action. |
Thus function assumes the agent alternates acting and observing. Simulation steps are triggered at startup (to construct the initial observation) and at each action request.
Note that there is currently a delay of three substeps between observation and simulation. That is, the internal simulation state is always three substeps ahead compared to the values written to the observation dictionary in cycle_actuation. This decision is discussed in https://github.com/orgs/upkie/discussions/238#discussioncomment-8984290
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Logger for the working_dict_ produced at each cycle.
|
protected |
|
protected |
State after the last Event::kCycleBeginning.
|
protected |
State after the last Event::kCycleEnd.
|
protected |
|
protected |