34 #include <visp3/core/vpConfig.h>
36 #if defined(VISP_HAVE_POLOLU) && defined(VISP_HAVE_THREADS)
38 #include <visp3/core/vpDebug.h>
39 #include <visp3/robot/vpRobot.h>
40 #include <visp3/robot/vpRobotException.h>
41 #include <visp3/robot/vpRobotPololuPtu.h>
47 m_pan.
connect(device, baudrate, 0);
52 m_tilt.
connect(device, baudrate, 1);
84 if (q.
size() !=
static_cast<unsigned int>(
nDof)) {
88 double s2 = sin(q[1]);
89 double c2 = cos(q[1]);
100 if (q.
size() !=
static_cast<unsigned int>(
nDof)) {
106 double s1 = sin(q[0]);
107 double c1 = cos(q[0]);
123 if (q.
size() !=
static_cast<unsigned int>(
nDof)) {
128 std::cout <<
"Warning: Robot is not in position-based control. Modification of the robot state" << std::endl;
160 if (q_dot.
size() !=
static_cast<unsigned int>(
nDof)) {
166 "Cannot send a velocity to the robot "
167 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
173 "in the camera frame:"
174 "functionality not implemented");
185 "in the reference frame:"
186 "functionality not implemented");
191 "functionality not implemented");
195 "in the end-effector frame:"
196 "functionality not implemented");
212 for (
unsigned int i = 0; i < static_cast<unsigned int>(
nDof); ++i) {
213 if (fabs(q_dot[i]) > max) {
215 max = fabs(q_dot[i]);
224 q_dot_sat = q_dot * max;
227 std::cout <<
"Send velocity: " << q_dot_sat.
t() << std::endl;
244 std::cout <<
"Switch from velocity to position control." << std::endl;
293 #elif !defined(VISP_BUILD_SHARED_LIBS)
295 void dummy_vpRobotPololuPtu() { };
void resize(unsigned int nrows, unsigned int ncols, bool flagNullify=true, bool recopy_=true)
unsigned int size() const
Return the number of elements of the 2D array.
unsigned int getRows() const
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
error that can be emitted by ViSP classes.
@ dimensionError
Bad dimension.
static double rad(double deg)
Implementation of a matrix and operations on matrices.
void setVerbose(bool verbose)
float speedToRadS(short speed) const
void setAngularVelocity(float vel_rad_s)
void setAngularRange(float min_angle, float max_angle)
void setPwmRange(unsigned short min_pwm, unsigned short max_pwm)
void connect(const std::string &device, int baudrate, int channel)
float getAngularPosition() const
void setAngularPosition(float pos_rad, float vel_rad_s=0.f)
Error that can be emitted by the vpRobot class and its derivatives.
@ wrongStateError
Wrong robot state.
~vpRobotPololuPtu() vp_override
vpRobot::vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState) vp_override
void get_eJe(vpMatrix &eJe) vp_override
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) vp_override
vpRobotPololuPtu(const std::string &device="/dev/ttyACM0", int baudrate=9600, bool verbose=false)
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) vp_override
float getAngularVelocityResolution() const
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot) vp_override
void get_fJe(vpMatrix &fJe) vp_override
int nDof
number of degrees of freedom
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
virtual vpRobotStateType getRobotState(void) const
@ STATE_POSITION_CONTROL
Initialize the position controller.
@ STATE_VELOCITY_CONTROL
Initialize the velocity controller.
@ STATE_STOP
Stops robot motion especially in velocity and acceleration control.
double getMaxRotationVelocity(void) const
vpMatrix fJe
robot Jacobian expressed in the robot reference frame available
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)