blmc_drivers
sine_torque_control.hpp
Go to the documentation of this file.
1 
8 
9 namespace blmc_drivers{
10 
14 typedef std::shared_ptr<blmc_drivers::SafeMotor> SafeMotor_ptr;
15 
20 {
21 public:
27  SineTorqueControl(std::vector<SafeMotor_ptr> motor_list):
28  motor_list_(motor_list)
29  {
30  encoders_.clear();
31  velocities_.clear();
32  currents_.clear();
33  control_buffer_.clear();
34 
35  for(unsigned int i=0 ; i<motor_list.size() ; ++i)
36  {
37  encoders_.push_back(std::deque<double>());
38  currents_.push_back(std::deque<double>());
39  velocities_.push_back(std::deque<double>());
40  control_buffer_.push_back(std::deque<double>());
41  encoders_.back().clear();
42  velocities_.back().clear();
43  currents_.back().clear();
44  control_buffer_.back().clear();
45  }
46  stop_loop_=false;
47  }
48 
53  {
54  stop_loop_=true;
55  rt_thread_.join();
56  }
57 
61  void start_loop()
62  {
63  rt_thread_.create_realtime_thread(&SineTorqueControl::loop, this);
64  }
65 
69  void stop_loop();
70 
71 private:
72 
76  std::vector<SafeMotor_ptr> motor_list_;
80  real_time_tools::RealTimeThread rt_thread_;
81 
86  static THREAD_FUNCTION_RETURN_TYPE loop(void* instance_pointer)
87  {
88  ((SineTorqueControl*)(instance_pointer))->loop();
89  return THREAD_FUNCTION_RETURN_VALUE;
90  }
91 
99  void loop();
100 
105 
110 
114  std::vector<std::deque<double> > encoders_;
115 
119  std::vector<std::deque<double> > velocities_;
120 
124  std::vector<std::deque<double> > currents_;
125 
129  std::vector<std::deque<double> > control_buffer_;
130 
131 }; // end class SineTorqueControl definition
132 
133 }// namespace blmc_drivers
std::vector< std::deque< double > > encoders_
Encoder data.
Definition: sine_torque_control.hpp:114
real_time_tools::RealTimeThread rt_thread_
This is the real time thread object.
Definition: sine_torque_control.hpp:80
This namespace is the standard namespace of the package.
Definition: const_torque_control.cpp:12
std::vector< std::deque< double > > control_buffer_
control_buffer_
Definition: sine_torque_control.hpp:129
~SineTorqueControl()
Destroy the SineTorqueControl object.
Definition: sine_torque_control.hpp:52
void start_loop()
This method is a helper to start the thread loop.
Definition: sine_torque_control.hpp:61
std::vector< std::deque< double > > velocities_
Velocity data.
Definition: sine_torque_control.hpp:119
void stop_loop()
Stop the control and dump the data.
Definition: sine_torque_control.cpp:76
std::vector< SafeMotor_ptr > motor_list_
This is list of motors.
Definition: sine_torque_control.hpp:76
std::vector< std::deque< double > > currents_
current data
Definition: sine_torque_control.hpp:124
static THREAD_FUNCTION_RETURN_TYPE loop(void *instance_pointer)
this function is just a wrapper around the actual loop function, such that it can be spawned as a pos...
Definition: sine_torque_control.hpp:86
This is a basic PD controller to be used in the demos of this package.
Definition: sine_torque_control.hpp:19
SineTorqueControl(std::vector< SafeMotor_ptr > motor_list)
Construct a new SineTorqueControl object.
Definition: sine_torque_control.hpp:27
unsigned memory_buffer_size_
memory_buffer_size_ is the max size of the memory buffer.
Definition: sine_torque_control.hpp:109
void loop()
this is a simple control loop which runs at a kilohertz.
Definition: sine_torque_control.cpp:13
bool stop_loop_
managing the stopping of the loop
Definition: sine_torque_control.hpp:104
std::shared_ptr< blmc_drivers::SafeMotor > SafeMotor_ptr
This is a simple shortcut.
Definition: const_torque_control.hpp:15