1 |
|
|
/** |
2 |
|
|
* @file spi_motor_board.cpp |
3 |
|
|
* @author Felix Widmaier (felix.widmaier@tuebingen.mpg.de) |
4 |
|
|
* @author Manuel Wuthrich (manuel.wuthrich@gmail.com) |
5 |
|
|
* @author Maximilien Naveau (maximilien.naveau@gmail.com) |
6 |
|
|
* @brief This file implements the classes from |
7 |
|
|
* "blmc_drivers/devices/motor_board.hpp" |
8 |
|
|
* @version 0.1 |
9 |
|
|
* @date 2018-11-26 |
10 |
|
|
* |
11 |
|
|
* @copyright Copyright (c) 2020, New York University and Max Planck Gesellshaft. |
12 |
|
|
* |
13 |
|
|
*/ |
14 |
|
|
|
15 |
|
|
#include "real_time_tools/timer.hpp" |
16 |
|
|
#include "blmc_drivers/devices/spi_motor_board.hpp" |
17 |
|
|
|
18 |
|
|
|
19 |
|
|
namespace rt = real_time_tools; |
20 |
|
|
|
21 |
|
|
|
22 |
|
|
namespace blmc_drivers |
23 |
|
|
{ |
24 |
|
|
|
25 |
|
|
SpiMotorBoard::SpiMotorBoard(std::shared_ptr<SpiBus> spi_bus, |
26 |
|
|
const size_t udriver_id): MotorBoardInterface() |
27 |
|
|
{ |
28 |
|
|
// Save the ser input |
29 |
|
|
spi_bus_ = spi_bus; |
30 |
|
|
udriver_id_ = udriver_id; |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
SpiMotorBoard::~SpiMotorBoard() |
34 |
|
|
{ |
35 |
|
|
} |
36 |
|
|
|
37 |
|
|
/** |
38 |
|
|
* Output and status |
39 |
|
|
*/ |
40 |
|
|
|
41 |
|
|
std::shared_ptr<const MotorBoardInterface::ScalarTimeseries> SpiMotorBoard:: |
42 |
|
|
get_measurement(const int& index) const |
43 |
|
|
{ |
44 |
|
|
return spi_bus_->get_measurement( |
45 |
|
|
udriver_id_, (MotorBoardInterface::MeasurementIndex)index); |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
std::shared_ptr<const MotorBoardInterface::StatusTimeseries> |
49 |
|
|
SpiMotorBoard::get_status() const |
50 |
|
|
{ |
51 |
|
|
return spi_bus_->get_status(udriver_id_); |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
/** |
55 |
|
|
* input logs |
56 |
|
|
*/ |
57 |
|
|
|
58 |
|
|
std::shared_ptr<const MotorBoardInterface::ScalarTimeseries> |
59 |
|
|
SpiMotorBoard::get_control(const int& index) const |
60 |
|
|
{ |
61 |
|
|
return spi_bus_->get_control( |
62 |
|
|
udriver_id_, (MotorBoardInterface::ControlIndex)index); |
63 |
|
|
} |
64 |
|
|
|
65 |
|
|
std::shared_ptr<const MotorBoardInterface::CommandTimeseries> |
66 |
|
|
SpiMotorBoard::get_command() const |
67 |
|
|
{ |
68 |
|
|
return spi_bus_->get_command(udriver_id_); |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
std::shared_ptr<const MotorBoardInterface::ScalarTimeseries> SpiMotorBoard:: |
72 |
|
|
get_sent_control(const int& index) const |
73 |
|
|
{ |
74 |
|
|
return spi_bus_->get_sent_control( |
75 |
|
|
udriver_id_, (MotorBoardInterface::ControlIndex)index); |
76 |
|
|
} |
77 |
|
|
|
78 |
|
|
std::shared_ptr<const MotorBoardInterface::CommandTimeseries> |
79 |
|
|
SpiMotorBoard::get_sent_command() const |
80 |
|
|
{ |
81 |
|
|
return spi_bus_->get_sent_command(udriver_id_); |
82 |
|
|
} |
83 |
|
|
|
84 |
|
|
/** |
85 |
|
|
* Setters |
86 |
|
|
*/ |
87 |
|
|
|
88 |
|
|
void SpiMotorBoard::set_control(const double& control, |
89 |
|
|
const int& index) |
90 |
|
|
{ |
91 |
|
|
spi_bus_->set_control( |
92 |
|
|
udriver_id_, control, (MotorBoardInterface::ControlIndex)index); |
93 |
|
|
} |
94 |
|
|
|
95 |
|
|
void SpiMotorBoard::set_command(const MotorBoardCommand& command) |
96 |
|
|
{ |
97 |
|
|
spi_bus_->set_command(udriver_id_, command); |
98 |
|
|
} |
99 |
|
|
|
100 |
|
|
void SpiMotorBoard::send_if_input_changed() |
101 |
|
|
{ |
102 |
|
|
spi_bus_->send_if_input_changed(); |
103 |
|
|
} |
104 |
|
|
|
105 |
✓✗✓✗
|
3 |
} // namespace blmc_drivers |