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>
48 m_pan.
connect(device, baudrate, 0);
53 m_tilt.
connect(device, baudrate, 1);
85 if (q.
size() !=
static_cast<unsigned int>(
nDof)) {
89 double s2 = sin(q[1]);
90 double c2 = cos(q[1]);
101 if (q.
size() !=
static_cast<unsigned int>(
nDof)) {
107 double s1 = sin(q[0]);
108 double c1 = cos(q[0]);
124 if (q.
size() !=
static_cast<unsigned int>(
nDof)) {
129 std::cout <<
"Warning: Robot is not in position-based control. Modification of the robot state" << std::endl;
161 if (q_dot.
size() !=
static_cast<unsigned int>(
nDof)) {
167 "Cannot send a velocity to the robot "
168 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
174 "in the camera frame:"
175 "functionality not implemented");
186 "in the reference frame:"
187 "functionality not implemented");
192 "functionality not implemented");
196 "in the end-effector frame:"
197 "functionality not implemented");
213 for (
unsigned int i = 0; i < static_cast<unsigned int>(
nDof); ++i) {
214 if (fabs(q_dot[i]) > max) {
216 max = fabs(q_dot[i]);
217 vpERROR_TRACE(
"Excess velocity: ROTATION "
225 q_dot_sat = q_dot * max;
228 std::cout <<
"Send velocity: " << q_dot_sat.
t() << std::endl;
245 std::cout <<
"Switch from velocity to position control." << std::endl;
294 #elif !defined(VISP_BUILD_SHARED_LIBS)
296 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.
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot) VP_OVERRIDE
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) VP_OVERRIDE
void get_eJe(vpMatrix &eJe) VP_OVERRIDE
~vpRobotPololuPtu() VP_OVERRIDE
vpRobotPololuPtu(const std::string &device="/dev/ttyACM0", int baudrate=9600, bool verbose=false)
vpRobot::vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState) VP_OVERRIDE
float getAngularVelocityResolution() const
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) 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)