upkie 6.1.0
Open-source wheeled biped robots
Loading...
Searching...
No Matches
upkie::cpp::actuation::MockInterface Class Reference

Interface whose internal state perfectly tracks commands. More...

#include <MockInterface.h>

Public Member Functions

 MockInterface (const double dt)
 Create mock actuator interface. More...
 
 ~MockInterface ()=default
 Default destructor.
 
void reset (const Dictionary &config) override
 Reset interface. More...
 
void observe (Dictionary &observation) const override
 Write actuation-interface observations to dictionary. More...
 
void process_action (const Dictionary &action) override
 Process a new action dictionary. More...
 
void cycle (std::function< void(const moteus::Output &)> callback) final
 Simulate a new communication cycle. More...
 
- Public Member Functions inherited from upkie::cpp::actuation::Interface
 Interface ()
 Initialize actuation interface for a given servo layout.
 
virtual ~Interface ()=default
 Virtual destructor so that derived destructors are called properly.
 
virtual void cycle (std::function< void(const moteus::Output &)> callback)=0
 Spin a new communication cycle. More...
 
virtual void reset (const Dictionary &config)=0
 Reset interface. More...
 
virtual void observe (Dictionary &observation) const =0
 Write servo and IMU observations to dictionary. More...
 
const ServoLayoutservo_layout () const noexcept
 Get servo layout.
 
const std::map< int, int > & servo_bus_map () const noexcept
 Map from servo ID to the CAN bus the servo is connected to.
 
const std::map< int, std::string > & servo_name_map () const noexcept
 Map from servo ID to joint name.
 
std::vector< moteus::ServoCommand > & commands ()
 Get servo commands.
 
const std::vector< moteus::ServoReply > & replies () const
 Get servo replies.
 
moteus::Data & data ()
 Get joint command-reply data. More...
 
void reset_action (Dictionary &action)
 Reset action dictionary to the default action. More...
 
virtual void process_action (const Dictionary &action)=0
 Process a new action dictionary. More...
 
void write_position_commands (const Dictionary &action)
 Write position commands from an action dictionary. More...
 
void write_stop_commands () noexcept
 Stop all servos. More...
 
void observe_imu (Dictionary &observation) const
 Observe IMU measurements. More...
 

Additional Inherited Members

- Protected Attributes inherited from upkie::cpp::actuation::Interface
moteus::Data data_
 Pointers to the memory shared with the CAN thread. More...
 
ImuData imu_data_
 IMU data.
 

Detailed Description

Interface whose internal state perfectly tracks commands.

Constructor & Destructor Documentation

◆ MockInterface()

upkie::cpp::actuation::MockInterface::MockInterface ( const double  dt)
explicit

Create mock actuator interface.

Parameters
[in]dtSimultation timestep in [s].

Member Function Documentation

◆ cycle()

void upkie::cpp::actuation::MockInterface::cycle ( std::function< void(const moteus::Output &)>  callback)
finalvirtual

Simulate a new communication cycle.

Parameters
callbackFunction to call when the cycle is over.

The callback will be invoked from an arbitrary thread when the communication cycle has completed. All memory pointed to by data must remain valid until the callback is invoked.

Implements upkie::cpp::actuation::Interface.

◆ observe()

void upkie::cpp::actuation::MockInterface::observe ( Dictionary &  observation) const
overridevirtual

Write actuation-interface observations to dictionary.

Parameters
[out]observationDictionary to write to.

Implements upkie::cpp::actuation::Interface.

◆ process_action()

void upkie::cpp::actuation::MockInterface::process_action ( const Dictionary &  action)
overridevirtual

Process a new action dictionary.

Parameters
[in]actionAction to read commands from.

Implements upkie::cpp::actuation::Interface.

◆ reset()

void upkie::cpp::actuation::MockInterface::reset ( const Dictionary &  config)
overridevirtual

Reset interface.

Parameters
[in]configAdditional configuration dictionary.

Implements upkie::cpp::actuation::Interface.


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