Skeletal Animation Multithread Face
exoskeleton.cpp
Go to the documentation of this file.
1#include "../include/exoskeleton.h"
2
10void Exoskeleton::initialize(const std::string& serial_com,
11 unsigned int serial_baudrate)
12{
13 // Generate serial communication channel
14 m_serial = std::make_shared<SerialCOM>(serial_com, serial_baudrate);
15
16 // Initialize stream
17 m_serial->initialize_stream();
18
19 // Initialize asychronous function
21}
22
37std::vector<double> Exoskeleton::incoming_data_callback(void)
38{
39 while(!m_return_value)
40 {
43 }
44
45 return m_raw_sensor_data;
46}
47
55std::vector<double> Exoskeleton::get_joint_angles(void)
56{
57 // Set termination flag for asychronous function
59
60 // Get joint angles from future function
61 std::vector<double> joint_angles = m_future_fun.get();
62
63 // Convert to rad
64 for (size_t i = 0; i < joint_angles.size(); i++)
65 {
66 joint_angles.at(i) = Utils::deg2rad(joint_angles.at(i));
67 }
68
69 // Reinitialize async function
72
73 return joint_angles;
74}
void initialize(const std::string &serial_com, unsigned int serial_baudrate)
Initialize the exoskeleton.
Definition: exoskeleton.cpp:10
std::vector< double > get_joint_angles(void)
Get joint angles.
Definition: exoskeleton.cpp:55
std::vector< double > m_raw_sensor_data
Sensors data vector (raw).
Definition: exoskeleton.h:42
std::shared_ptr< SerialCOM > m_serial
Serial communication handler.
Definition: exoskeleton.h:47
bool m_return_value
Termination flag for callback function.
Definition: exoskeleton.h:53
std::future< std::vector< double > > m_future_fun
Future function handle.
Definition: exoskeleton.h:50
std::vector< double > incoming_data_callback(void)
Read incoming data.
Definition: exoskeleton.cpp:37
static std::vector< double > analog_str_buf_to_double_vec(const std::string &str)
Convert comma-delimited string to double vector of analog values.
Definition: utils.cpp:34
static double deg2rad(double deg)
Convert degrees to rad.
Definition: utils.h:30