blmc_drivers
const_torque_control.hpp
Go to the documentation of this file.
1 
9 
10 namespace blmc_drivers{
11 
15 typedef std::shared_ptr<blmc_drivers::SafeMotor> SafeMotor_ptr;
16 
21 {
22 public:
28  ConstTorqueControl(std::vector<SafeMotor_ptr> motor_list):
29  motor_list_(motor_list)
30  {
31  encoders_.clear();
32  velocities_.clear();
33  currents_.clear();
34  control_buffer_.clear();
35 
36  for(std::size_t i=0 ; i<motor_list.size() ; ++i)
37  {
38  encoders_.push_back(std::deque<double>());
39  currents_.push_back(std::deque<double>());
40  velocities_.push_back(std::deque<double>());
41  control_buffer_.push_back(std::deque<double>());
42  encoders_.back().clear();
43  velocities_.back().clear();
44  currents_.back().clear();
45  control_buffer_.back().clear();
46  }
47  stop_loop_=false;
48  }
49 
54  {
55  stop_loop_=true;
56  rt_thread_.join();
57  }
58 
62  void start_loop()
63  {
64  rt_thread_.create_realtime_thread(&ConstTorqueControl::loop, this);
65  }
66 
70  void stop_loop();
71 
72 private:
73 
77  std::vector<SafeMotor_ptr> motor_list_;
81  real_time_tools::RealTimeThread rt_thread_;
82 
87  static THREAD_FUNCTION_RETURN_TYPE loop(void* instance_pointer)
88  {
89  ((ConstTorqueControl*)(instance_pointer))->loop();
90  return THREAD_FUNCTION_RETURN_VALUE;
91  }
92 
100  void loop();
101 
106 
111 
115  std::vector<std::deque<double> > encoders_;
116 
120  std::vector<std::deque<double> > velocities_;
121 
125  std::vector<std::deque<double> > currents_;
126 
130  std::vector<std::deque<double> > control_buffer_;
131 
132 }; // end class ConstTorqueControl definition
133 
134 }// namespace blmc_drivers
std::vector< std::deque< double > > currents_
current data
Definition: const_torque_control.hpp:125
~ConstTorqueControl()
Destroy the ConstTorqueControl object.
Definition: const_torque_control.hpp:53
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: const_torque_control.hpp:130
std::vector< std::deque< double > > encoders_
Encoder data.
Definition: const_torque_control.hpp:115
std::vector< std::deque< double > > velocities_
Velocity data.
Definition: const_torque_control.hpp:120
bool stop_loop_
managing the stopping of the loop
Definition: const_torque_control.hpp:105
void stop_loop()
Stop the control and dump the data.
Definition: const_torque_control.cpp:70
ConstTorqueControl(std::vector< SafeMotor_ptr > motor_list)
Construct a new ConstTorqueControl object.
Definition: const_torque_control.hpp:28
void start_loop()
This method is a helper to start the thread loop.
Definition: const_torque_control.hpp:62
std::vector< SafeMotor_ptr > motor_list_
This is list of motors.
Definition: const_torque_control.hpp:77
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: const_torque_control.hpp:87
void loop()
this is a simple control loop which runs at a kilohertz.
Definition: const_torque_control.cpp:14
unsigned memory_buffer_size_
memory_buffer_size_ is the max size of the memory buffer.
Definition: const_torque_control.hpp:110
This is a basic PD controller to be used in the demos of this package.
Definition: const_torque_control.hpp:20
real_time_tools::RealTimeThread rt_thread_
This is the real time thread object.
Definition: const_torque_control.hpp:81
std::shared_ptr< blmc_drivers::SafeMotor > SafeMotor_ptr
This is a simple shortcut.
Definition: const_torque_control.hpp:15