37 #include <visp3/core/vpConfig.h>
39 #if defined(VISP_HAVE_POLOLU) && defined(VISP_HAVE_THREADS)
45 class RPMSerialInterface;
97 vpPololu(
const std::string &device,
int baudrate = 38400,
int channel = 0,
bool verbose =
false);
111 void calibrate(
unsigned short &pwm_min,
unsigned short &pwm_max);
120 void connect(
const std::string &device,
int baudrate,
int channel);
127 bool connected()
const;
134 float getAngularPosition()
const;
141 unsigned short getPwmPosition()
const;
152 void getRangeAngles(
float &minAngle,
float &maxAngle)
const;
163 void getRangePwm(
unsigned short &min,
unsigned short &max);
173 void setAngularPosition(
float pos_rad,
float vel_rad_s = 0.f);
186 m_min_angle = min_angle;
187 m_max_angle = max_angle;
188 m_range_angle = m_max_angle - m_min_angle;
196 void setAngularVelocity(
float vel_rad_s);
207 void setPwmPosition(
unsigned short pos_pwm,
unsigned short speed_pwm = 0);
218 inline void setPwmRange(
unsigned short min_pwm,
unsigned short max_pwm)
222 m_range_pwm = m_max_pwm - m_min_pwm;
232 void setPwmVelocity(
short pwm_vel);
247 void stopVelocityCmd();
262 float pwmToRad(
unsigned short pwm)
const;
273 unsigned short radToPwm(
float angle)
const;
284 short radSToSpeed(
float speed_rad_s)
const;
295 float speedToRadS(
short speed)
const;
299 static RPMSerialInterface *m_interface;
300 static int m_nb_servo;
303 bool m_apply_velocity_cmd;
304 bool m_stop_velocity_cmd_thread;
306 unsigned short m_vel_speed;
307 unsigned short m_vel_target_position;
309 unsigned short m_vel_speed_prev;
310 unsigned short m_vel_target_position_prev;
312 std::mutex m_mutex_velocity_cmd;
315 unsigned short m_min_pwm = 4095;
316 unsigned short m_max_pwm = 7905;
317 unsigned short m_range_pwm = m_max_pwm - m_min_pwm;
318 float m_min_angle = -40;
319 float m_max_angle = 40;
320 float m_range_angle = abs(m_min_angle) + abs(m_max_angle);
330 void VelocityCmdThread();
Interface for the Pololu Maestro USB Servo Controllers.
void setVerbose(bool verbose)
void setAngularRange(float min_angle, float max_angle)
void setPwmRange(unsigned short min_pwm, unsigned short max_pwm)