15 #include "master_board_sdk/master_board_interface.h" 17 #include "real_time_tools/thread.hpp" 18 #include "real_time_tools/threadsafe/threadsafe_timeseries.hpp" 42 std::shared_ptr<MasterBoardInterface> main_board_interface,
43 const size_t& nb_udrivers,
const size_t& history_length=1000);
62 virtual std::shared_ptr<const MotorInterface::ScalarTimeseries>
64 const size_t udriver_id,
71 virtual std::shared_ptr<const MotorBoardInterface::StatusTimeseries>
82 virtual std::shared_ptr<const MotorInterface::ScalarTimeseries>
get_control(
83 const size_t udriver_id,
90 virtual std::shared_ptr<const MotorBoardInterface::CommandTimeseries>
97 virtual std::shared_ptr<const MotorInterface::ScalarTimeseries>
99 const size_t udriver_id,
106 virtual std::shared_ptr<const MotorBoardInterface::CommandTimeseries>
117 virtual void set_control(
const size_t udriver_id,
const double& control,
157 static THREAD_FUNCTION_RETURN_TYPE
loop(
void* instance_pointer)
159 static_cast<SpiBus*
>(instance_pointer)->
loop();
160 return THREAD_FUNCTION_RETURN_VALUE;
205 std::vector<std::shared_ptr<MotorInterface::ScalarTimeseries> >
measurement_;
210 std::vector<std::shared_ptr<MotorBoardInterface::StatusTimeseries> >
status_;
219 std::vector<std::shared_ptr<MotorInterface::ScalarTimeseries> >
control_;
224 std::vector<std::shared_ptr<MotorBoardInterface::CommandTimeseries> >
command_;
237 std::vector<std::shared_ptr<MotorInterface::ScalarTimeseries> >
sent_control_;
242 std::vector<std::shared_ptr<MotorBoardInterface::CommandTimeseries> >
sent_command_;
std::vector< std::shared_ptr< MotorBoardInterface::CommandTimeseries > > sent_command_
This is the history of the already sent commands.
Definition: spi_bus.hpp:242
std::vector< std::shared_ptr< MotorInterface::ScalarTimeseries > > control_
Inputs.
Definition: spi_bus.hpp:219
virtual void send_if_input_changed()
Actually send the commands and the controls.
Definition: spi_bus.cpp:152
bool is_ready()
return s only once board and motors are ready.
Definition: spi_bus.cpp:276
std::array< bool, 12 > motor_index_toggle_bits_
Everytime a motor index is detected the corresponding bit change for the opposite value...
Definition: spi_bus.hpp:281
This namespace is the standard namespace of the package.
Definition: const_torque_control.cpp:12
std::vector< std::shared_ptr< MotorBoardInterface::StatusTimeseries > > status_
This is the status history of the udriver board.
Definition: spi_bus.hpp:210
virtual std::shared_ptr< const MotorInterface::ScalarTimeseries > get_measurement(const size_t udriver_id, const MotorBoardInterface::MeasurementIndex &index) const
Output and status.
Definition: spi_bus.cpp:89
std::shared_ptr< MasterBoardInterface > main_board_interface_
Communication related attributes.
Definition: spi_bus.hpp:189
bool motors_are_paused_
Are motor in idle mode = 0 torques.
Definition: spi_bus.hpp:257
real_time_tools::RealTimeThread rt_thread_
This is the thread object that allow to spwan a real-time thread or not dependening on the current OS...
Definition: spi_bus.hpp:269
bool is_loop_active_
Loop management.
Definition: spi_bus.hpp:252
void wait_until_ready()
Wait until the robot is ready.
Definition: spi_bus.cpp:393
This MotorBoardCommand class is a data structurs that defines a command.
Definition: motor_board.hpp:30
virtual std::shared_ptr< const MotorBoardInterface::CommandTimeseries > get_sent_command(const size_t udriver_id) const
Get the sent commands.
Definition: spi_bus.cpp:130
~SpiBus()
Destroy the SpiBus object.
Definition: spi_bus.cpp:66
int control_timeout_ms_
If no control is sent for more than control_timeout_ms_ the board will shut down. ...
Definition: spi_bus.hpp:263
virtual void set_control(const size_t udriver_id, const double &control, const MotorBoardInterface::ControlIndex &index)
Setters.
Definition: spi_bus.cpp:139
SpiBus(std::shared_ptr< MasterBoardInterface > main_board_interface, const size_t &nb_udrivers, const size_t &history_length=1000)
Construct a new SpiBus object.
Definition: spi_bus.cpp:25
MeasurementIndex
This is the list of the measurement we can access.
Definition: motor_board.hpp:249
virtual std::shared_ptr< const MotorInterface::ScalarTimeseries > get_control(const size_t udriver_id, const MotorBoardInterface::ControlIndex &index) const
input logs
Definition: spi_bus.cpp:108
static THREAD_FUNCTION_RETURN_TYPE loop(void *instance_pointer)
Private methods.
Definition: spi_bus.hpp:157
this class exists purely for logical reasons, it does not in itself implement anything.
Definition: device_interface.hpp:36
size_t history_length_
history_length_ is the length of data buffers in number of iteration.
Definition: spi_bus.hpp:228
std::vector< std::shared_ptr< MotorInterface::ScalarTimeseries > > measurement_
Outputs.
Definition: spi_bus.hpp:205
virtual std::shared_ptr< const MotorInterface::ScalarTimeseries > get_sent_control(const size_t udriver_id, const MotorBoardInterface::ControlIndex &index) const
Get the sent controls.
Definition: spi_bus.cpp:122
virtual std::shared_ptr< const MotorBoardInterface::StatusTimeseries > get_status(const size_t udriver_id) const
Get the status of the motor board.
Definition: spi_bus.cpp:98
void loop()
This is the real time thread that streams the data to/from the main board.
Definition: spi_bus.cpp:292
size_t nb_udrivers_
nb_udrivers_ is the number of the udriver controlled by the main board.
Definition: spi_bus.hpp:195
virtual std::shared_ptr< const MotorBoardInterface::CommandTimeseries > get_command(const size_t udriver_id) const
Get the commands to be send.
Definition: spi_bus.cpp:116
std::vector< std::shared_ptr< MotorBoardInterface::CommandTimeseries > > command_
This is the buffer of the commands to be sent to the card.
Definition: spi_bus.hpp:224
std::vector< std::shared_ptr< MotorInterface::ScalarTimeseries > > sent_control_
Log.
Definition: spi_bus.hpp:237
Definition: spi_bus.hpp:25
virtual void set_command(const size_t udriver_id, const MotorBoardCommand &command)
set_command save the command internally.
Definition: spi_bus.cpp:146
ControlIndex
This is the list of the controls we can send.
Definition: motor_board.hpp:259
void send_newest_command()
Send the newest control stored in the time series.
Definition: spi_bus.cpp:184
void send_newest_controls()
Send the newest control stored in the time series.
Definition: spi_bus.cpp:252