45 #include <visp/vpConfig.h>
46 #ifdef VISP_HAVE_PTU46
49 #include <visp/vpPtu46.h>
50 #include <visp/vpRobotPtu46.h>
51 #include <visp/vpRobotException.h>
52 #include <visp/vpDebug.h>
58 bool vpRobotPtu46::robotAlreadyCreated =
false;
75 vpRobotPtu46::vpRobotPtu46 (
const char *device)
79 this->device =
new char [FILENAME_MAX];
81 sprintf(this->device,
"%s", device);
90 delete [] this->device;
101 delete [] this->device;
124 if (0 != ptu.close())
126 vpERROR_TRACE (
"Error while closing communications with the robot ptu-46.");
129 vpRobotPtu46::robotAlreadyCreated =
false;
155 if (0 != ptu.init(device) )
159 "Cannot open connexion with ptu-46");
323 positioningVelocity = velocity;
334 return positioningVelocity;
362 "Modification of the robot state");
372 "Cannot move the robot in camera frame: "
379 "Cannot move the robot in reference frame: "
386 "Cannot move the robot in mixt frame: "
399 if (0 != ptu.move(artpos, positioningVelocity, PTU_ABSOLUTE_MODE) )
403 "Positionning error.");
428 const double &q1,
const double &q2)
464 "Cannot get ptu-46 position from file");
491 vpERROR_TRACE (
"Cannot get position in camera frame: not implemented");
493 "Cannot get position in camera frame: "
500 "Cannot get position in reference frame: "
507 "Cannot get position in mixt frame: "
516 if (0 != ptu.getCurrentPosition( artpos ) )
520 "Error when calling recup_posit_Afma4.");
563 TPtuFrame ptuFrameInterface;
568 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
570 "Cannot send a velocity to the robot "
571 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
578 ptuFrameInterface = PTU_CAMERA_FRAME;
580 vpERROR_TRACE (
"Bad dimension fo speed vector in camera frame");
582 "Bad dimension for speed vector "
589 ptuFrameInterface = PTU_ARTICULAR_FRAME;
591 vpERROR_TRACE (
"Bad dimension fo speed vector in articular frame");
593 "Bad dimension for speed vector "
594 "in articular frame");
601 "in the reference frame: "
602 "functionality not implemented");
604 "Cannot send a velocity to the robot "
605 "in the reference frame:"
606 "functionality not implemented");
612 "in the mixt frame: "
613 "functionality not implemented");
615 "Cannot send a velocity to the robot "
617 "functionality not implemented");
623 "Case not taken in account.");
625 "Cannot send a velocity to the robot ");
631 double ptuSpeedInterface[2];
636 double max =
this ->maxRotationVelocity;
637 for (
unsigned int i = 0 ; i < 2; ++ i)
639 if (fabs (v[i]) > max)
649 max =
this ->maxRotationVelocity / max;
650 for (
unsigned int i = 0 ; i < 2; ++ i)
651 ptuSpeedInterface [i] = v[i]*max;
661 vpCDEBUG(12) <<
"v: " << ptuSpeedInterface[0]
662 <<
" " << ptuSpeedInterface[1] << std::endl;
663 ptu.move(ptuSpeedInterface, ptuFrameInterface);
689 TPtuFrame ptuFrameInterface = PTU_ARTICULAR_FRAME;
696 "functionality not implemented");
698 "Cannot get a velocity in the camera frame:"
699 "functionality not implemented");
704 ptuFrameInterface = PTU_ARTICULAR_FRAME;
709 vpERROR_TRACE (
"Cannot get a velocity in the reference frame: "
710 "functionality not implemented");
712 "Cannot get a velocity in the reference frame:"
713 "functionality not implemented");
720 "functionality not implemented");
722 "Cannot get a velocity in the mixt frame:"
723 "functionality not implemented");
729 double ptuSpeedInterface[2];
731 ptu.getCurrentSpeed(ptuSpeedInterface, ptuFrameInterface);
733 q_dot[0] = ptuSpeedInterface[0];
734 q_dot[1] = ptuSpeedInterface[1];
782 pt_f = fopen(filename,
"r") ;
785 vpERROR_TRACE (
"Can not open ptu-46 position file %s", filename);
789 char line[FILENAME_MAX];
795 if (fgets (line, 100, pt_f) != NULL) {
796 if ( strncmp (line,
"#", 1) != 0) {
798 if ( fscanf (pt_f,
"%s", line) != EOF) {
799 if ( strcmp (line, head) == 0)
811 while ( end !=
true );
815 fscanf(pt_f,
"%lf %lf", &q1, &q2);
838 vpRobotPtu46::getCameraDisplacement(
vpColVector &v)
854 void vpRobotPtu46::getArticularDisplacement(
vpColVector &d)
891 ptu.measureDpl(d_, PTU_CAMERA_FRAME);
902 ptu.measureDpl(d_, PTU_ARTICULAR_FRAME);
910 vpERROR_TRACE (
"Cannot get a displacement in the reference frame: "
911 "functionality not implemented");
913 "Cannot get a displacement in the reference frame:"
914 "functionality not implemented");
919 vpERROR_TRACE (
"Cannot get a displacement in the mixt frame: "
920 "functionality not implemented");
922 "Cannot get a displacement in the reference frame:"
923 "functionality not implemented");
Definition of the vpMatrix class.
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
Error that can be emited by the vpRobot class and its derivates.
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q)
void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q_dot)
The class provides a data structure for the homogeneous matrices as well as a set of operations on th...
void get_cMe(vpHomogeneousMatrix &_cMe) const
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot)
static const double defaultPositioningVelocity
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q)
Initialize the position controller.
void getDisplacement(vpRobot::vpControlFrameType frame, vpColVector &q)
class that defines a generic virtual robot
void get_fJe(vpMatrix &_fJe)
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
void get_cMe(vpHomogeneousMatrix &_cMe) const
Initialize the velocity controller.
static const unsigned int ndof
virtual ~vpRobotPtu46(void)
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
Class that consider the particular case of twist transformation matrix that allows to transform a vel...
void get_eJe(vpMatrix &_eJe)
static double rad(double deg)
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
void get_cVe(vpVelocityTwistMatrix &_cVe) const
double getPositioningVelocity(void)
Class that provides a data structure for the column vectors as well as a set of operations on these v...
virtual vpRobotStateType getRobotState(void) const
unsigned int getRows() const
Return the number of rows of the matrix.
bool readPositionFile(const char *filename, vpColVector &q)
void setPositioningVelocity(const double velocity)
void resize(const unsigned int i, const bool flagNullify=true)