blmc_drivers
blmc_drivers::SpiMotorBoard Class Reference
Inheritance diagram for blmc_drivers::SpiMotorBoard:
Collaboration diagram for blmc_drivers::SpiMotorBoard:

Public Member Functions

 SpiMotorBoard (std::shared_ptr< SpiBus > spi_bus, const size_t udriver_id)
 Construct a new SpiMotorBoard object. More...
 
 ~SpiMotorBoard ()
 Destroy the SpiMotorBoard object. More...
 
virtual std::shared_ptr< const MotorInterface::ScalarTimeseriesget_measurement (const int &index) const
 Output and status. More...
 
virtual std::shared_ptr< const MotorBoardInterface::StatusTimeseriesget_status () const
 Get the status of the motor board. More...
 
virtual std::shared_ptr< const MotorInterface::ScalarTimeseriesget_control (const int &index) const
 input logs More...
 
virtual std::shared_ptr< const MotorBoardInterface::CommandTimeseriesget_command () const
 Get the commands to be send. More...
 
virtual std::shared_ptr< const MotorInterface::ScalarTimeseriesget_sent_control (const int &index) const
 Get the sent controls. More...
 
virtual std::shared_ptr< const MotorBoardInterface::CommandTimeseriesget_sent_command () const
 Get the sent commands. More...
 
virtual void set_control (const double &control, const int &index)
 Setters. More...
 
virtual void set_command (const MotorBoardCommand &command)
 set_command save the command internally. More...
 
virtual void send_if_input_changed ()
 Actually send the commands and the controls. More...
 
bool is_ready ()
 return s only once board and motors are ready.
 
- Public Member Functions inherited from blmc_drivers::MotorBoardInterface
virtual ~MotorBoardInterface ()
 Destroy the MotorBoardInterface object.
 

Private Attributes

std::shared_ptr< SpiBusspi_bus_
 Communication related attributes. More...
 
size_t udriver_id_
 udriver_id_ is the index of the udriver controlled by the master board. More...
 

Additional Inherited Members

- Public Types inherited from blmc_drivers::MotorBoardInterface
enum  MeasurementIndex {
  current_0, current_1, position_0, position_1,
  velocity_0, velocity_1, analog_0, analog_1,
  encoder_index_0, encoder_index_1, measurement_count
}
 This is the list of the measurement we can access.
 
enum  ControlIndex { current_target_0, current_target_1, control_count }
 This is the list of the controls we can send.
 
typedef real_time_tools::ThreadsafeTimeseries< double > ScalarTimeseries
 A useful shortcut.
 
typedef ScalarTimeseries::Index Index
 A useful shortcut.
 
typedef real_time_tools::ThreadsafeTimeseries< IndexIndexTimeseries
 A useful shortcut.
 
typedef real_time_tools::ThreadsafeTimeseries< MotorBoardStatusStatusTimeseries
 A useful shortcut.
 
typedef real_time_tools::ThreadsafeTimeseries< MotorBoardCommandCommandTimeseries
 A useful shortcut.
 
template<typename Type >
using Ptr = std::shared_ptr< Type >
 A useful shortcut.
 
template<typename Type >
using Vector = std::vector< Type >
 A useful shortcut.
 

Constructor & Destructor Documentation

◆ SpiMotorBoard()

blmc_drivers::SpiMotorBoard::SpiMotorBoard ( std::shared_ptr< SpiBus spi_bus,
const size_t  udriver_id 
)

Construct a new SpiMotorBoard object.

The constructor starts a real time thread: SpiMotorBoard::loop(). This thread streams the data back and forth collecting the sensor data and sends the control/commands.

Parameters
spi_busis the object that communicate with the master board which in turn communicate with the motor boards. The master board provides the hardware informations and sends the commands.
udriver_idis the id of the udriver this class represents.

◆ ~SpiMotorBoard()

blmc_drivers::SpiMotorBoard::~SpiMotorBoard ( )

Destroy the SpiMotorBoard object.

The destructor handles the proper shutdown of the class and the threads.

Member Function Documentation

◆ get_command()

std::shared_ptr< const MotorBoardInterface::CommandTimeseries > blmc_drivers::SpiMotorBoard::get_command ( ) const
virtual

Get the commands to be send.

Returns
Ptr<const CommandTimeseries> is the list of the commands to be send. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

◆ get_control()

std::shared_ptr< const MotorBoardInterface::ScalarTimeseries > blmc_drivers::SpiMotorBoard::get_control ( const int &  index) const
virtual

input logs

input logs Get the controls to be send.

Parameters
indexdefine the kind of control we are looking for.
Returns
Ptr<const ScalarTimeseries> is the list of the controls to be send. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

◆ get_measurement()

std::shared_ptr< const MotorBoardInterface::ScalarTimeseries > blmc_drivers::SpiMotorBoard::get_measurement ( const int &  index) const
virtual

Output and status.

Getters. Get the measurements

Parameters
indexis the kind of measurement we are looking for.
Returns
Ptr<const ScalarTimeseries> is the list of the last time stamped measurement acquiered. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

◆ get_sent_command()

std::shared_ptr< const MotorBoardInterface::CommandTimeseries > blmc_drivers::SpiMotorBoard::get_sent_command ( ) const
virtual

Get the sent commands.

Returns
Ptr<const CommandTimeseries> is the list of the commands sent recently. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

◆ get_sent_control()

std::shared_ptr< const MotorBoardInterface::ScalarTimeseries > blmc_drivers::SpiMotorBoard::get_sent_control ( const int &  index) const
virtual

Get the sent controls.

Parameters
indexdefine the kind of control we are looking for.
Returns
Ptr<const ScalarTimeseries> is the list of the controls sent recently. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

◆ get_status()

std::shared_ptr< const MotorBoardInterface::StatusTimeseries > blmc_drivers::SpiMotorBoard::get_status ( ) const
virtual

Get the status of the motor board.

Returns
Ptr<const StatusTimeseries> is the list of the last status of the card. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

◆ send_if_input_changed()

void blmc_drivers::SpiMotorBoard::send_if_input_changed ( )
virtual

Actually send the commands and the controls.

Inherited from MotorBoardInterface. This particualr instance does not actually check if it is is a new command or control as the full status of the robot is exchange at every tick.

Implements blmc_drivers::MotorBoardInterface.

◆ set_command()

void blmc_drivers::SpiMotorBoard::set_command ( const MotorBoardCommand command)
virtual

set_command save the command internally.

In order to actaully send the controls to the network please call "send_if_input_changed"

Parameters
commandis the command to be sent. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

◆ set_control()

void blmc_drivers::SpiMotorBoard::set_control ( const double &  control,
const int &  index 
)
virtual

Setters.

Setters. set_control save the control internally. In order to actaully send the controls to the network please call "send_if_input_changed"

Parameters
controlis the value of the control.
indexdefine the kind of control we want to send. Inherited from MotorBoardInterface

Implements blmc_drivers::MotorBoardInterface.

Member Data Documentation

◆ spi_bus_

std::shared_ptr<SpiBus> blmc_drivers::SpiMotorBoard::spi_bus_
private

Communication related attributes.

Master board interface sdk: https://github.com/open-dynamic-robot-initiative/master-board

◆ udriver_id_

size_t blmc_drivers::SpiMotorBoard::udriver_id_
private

udriver_id_ is the index of the udriver controlled by the master board.

The index is the one used in MasterBoardInterface. The index should correspond to the hardware SPI index onboard the card.


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