39 #include <visp3/core/vpConfig.h>
40 #ifdef VISP_HAVE_PTU46
43 #include <visp3/core/vpDebug.h>
44 #include <visp3/core/vpIoTools.h>
45 #include <visp3/robot/vpPtu46.h>
46 #include <visp3/robot/vpRobotException.h>
47 #include <visp3/robot/vpRobotPtu46.h>
54 bool vpRobotPtu46::robotAlreadyCreated =
false;
70 vpRobotPtu46::vpRobotPtu46(
const std::string &device) :
vpRobot()
72 this->device = device;
74 vpDEBUG_TRACE(12,
"Open communication with Ptu-46.");
79 vpERROR_TRACE(
"Error caught");
87 vpERROR_TRACE(
"Error caught");
109 if (0 != ptu.close()) {
110 vpERROR_TRACE(
"Error while closing communications with the robot ptu-46.");
113 vpRobotPtu46::robotAlreadyCreated =
false;
136 vpDEBUG_TRACE(12,
"Open connection Ptu-46.");
137 if (0 != ptu.init(device.c_str())) {
138 vpERROR_TRACE(
"Cannot open connection with ptu-46.");
162 vpDEBUG_TRACE(12,
"Passage vitesse -> position.");
166 vpDEBUG_TRACE(1,
"Passage arret -> position.");
172 vpDEBUG_TRACE(10,
"Arret du robot...");
243 vpERROR_TRACE(
"catch exception ");
264 vpERROR_TRACE(
"Error caught");
304 vpERROR_TRACE(
"Robot was not in position-based control\n"
305 "Modification of the robot state");
336 if (0 != ptu.move(artpos, positioningVelocity, PTU_ABSOLUTE_MODE)) {
337 vpERROR_TRACE(
"Positioning error.");
370 vpERROR_TRACE(
"Error caught");
392 vpERROR_TRACE(
"Cannot get ptu-46 position from file");
413 vpDEBUG_TRACE(9,
"# Entree.");
438 if (0 != ptu.getCurrentPosition(artpos)) {
439 vpERROR_TRACE(
"Error when calling recup_posit_Afma4.");
481 TPtuFrame ptuFrameInterface;
484 vpERROR_TRACE(
"Cannot send a velocity to the robot "
485 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
487 "Cannot send a velocity to the robot "
488 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
493 ptuFrameInterface = PTU_CAMERA_FRAME;
495 vpERROR_TRACE(
"Bad dimension fo speed vector in camera frame");
502 ptuFrameInterface = PTU_ARTICULAR_FRAME;
505 "in articular frame");
511 "in the reference frame:"
512 "functionality not implemented");
517 "functionality not implemented");
521 "in the end-effector frame:"
522 "functionality not implemented");
529 vpDEBUG_TRACE(12,
"Velocity limitation.");
530 double ptuSpeedInterface[2];
537 for (
unsigned int i = 0; i < 2; ++i)
539 if (fabs(v[i]) > max) {
542 vpERROR_TRACE(
"Excess velocity: ROTATION "
550 for (
unsigned int i = 0; i < 2; ++i)
551 ptuSpeedInterface[i] = v[i] * max;
560 vpCDEBUG(12) <<
"v: " << ptuSpeedInterface[0] <<
" " << ptuSpeedInterface[1] << std::endl;
561 ptu.move(ptuSpeedInterface, ptuFrameInterface);
586 TPtuFrame ptuFrameInterface = PTU_ARTICULAR_FRAME;
591 "functionality not implemented");
594 ptuFrameInterface = PTU_ARTICULAR_FRAME;
599 "functionality not implemented");
603 "functionality not implemented");
607 "functionality not implemented");
612 double ptuSpeedInterface[2];
614 ptu.getCurrentSpeed(ptuSpeedInterface, ptuFrameInterface);
616 q_dot[0] = ptuSpeedInterface[0];
617 q_dot[1] = ptuSpeedInterface[1];
660 std::ifstream fd(filename.c_str(), std::ios::in);
667 std::string key(
"R:");
668 std::string id(
"#PTU-EVI - Position");
669 bool pos_found =
false;
674 while (std::getline(fd, line)) {
677 if (!(line.compare(0,
id.size(),
id) == 0)) {
678 std::cout <<
"Error: this position file " << filename <<
" is not for Ptu-46 robot" << std::endl;
682 if ((line.compare(0, 1,
"#") == 0)) {
685 if ((line.compare(0, key.size(), key) == 0)) {
693 std::istringstream ss(line);
709 std::cout <<
"Error: unable to find a position for Ptu-46 robot in " << filename << std::endl;
742 ptu.measureDpl(d_, PTU_CAMERA_FRAME);
752 ptu.measureDpl(d_, PTU_ARTICULAR_FRAME);
760 "functionality not implemented");
764 "functionality not implemented");
768 "functionality not implemented");
773 #elif !defined(VISP_BUILD_SHARED_LIBS)
775 void dummy_vpRobotPtu46() { };
unsigned int getRows() const
Implementation of column vector and the associated operations.
void resize(unsigned int i, bool flagNullify=true)
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
static const unsigned int ndof
void get_cMe(vpHomogeneousMatrix &_cMe) const
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Error that can be emitted by the vpRobot class and its derivatives.
@ wrongStateError
Wrong robot state.
@ constructionError
Error from constructor.
@ readingParametersError
Cannot parse parameters.
@ lowLevelError
Error thrown by the low level sdk.
void get_fJe(vpMatrix &_fJe) VP_OVERRIDE
void setPositioningVelocity(double velocity)
void get_eJe(vpMatrix &_eJe) VP_OVERRIDE
void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot) VP_OVERRIDE
double getPositioningVelocity(void)
void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q_dot)
void get_cVe(vpVelocityTwistMatrix &_cVe) const
static const double defaultPositioningVelocity
virtual ~vpRobotPtu46(void)
vpRobot::vpRobotStateType setRobotState(vpRobot::vpRobotStateType newState)
void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) VP_OVERRIDE
void get_cMe(vpHomogeneousMatrix &_cMe) const
bool readPositionFile(const std::string &filename, vpColVector &q)
void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) VP_OVERRIDE
void getDisplacement(vpRobot::vpControlFrameType frame, vpColVector &q)
Class that defines a generic virtual robot.
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.
vpMatrix fJe
robot Jacobian expressed in the robot reference frame available
virtual vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState)
double maxRotationVelocity
vpVelocityTwistMatrix & buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)