42 #include <visp3/core/vpConfig.h> 43 #ifdef VISP_HAVE_PTU46 46 #include <visp3/core/vpDebug.h> 47 #include <visp3/core/vpIoTools.h> 48 #include <visp3/robot/vpPtu46.h> 49 #include <visp3/robot/vpRobotException.h> 50 #include <visp3/robot/vpRobotPtu46.h> 56 bool vpRobotPtu46::robotAlreadyCreated =
false;
72 vpRobotPtu46::vpRobotPtu46(
const char *device) :
vpRobot()
74 this->device =
new char[FILENAME_MAX];
76 sprintf(this->device,
"%s", device);
82 delete[] this->device;
90 delete[] this->device;
113 if (0 != ptu.close()) {
114 vpERROR_TRACE(
"Error while closing communications with the robot ptu-46.");
117 vpRobotPtu46::robotAlreadyCreated =
false;
144 if (0 != ptu.init(device)) {
309 "Modification of the robot state");
342 if (0 != ptu.move(artpos, positioningVelocity, PTU_ABSOLUTE_MODE)) {
422 vpERROR_TRACE(
"Cannot get position in camera frame: not implemented");
444 if (0 != ptu.getCurrentPosition(artpos)) {
486 TPtuFrame ptuFrameInterface;
490 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
492 "Cannot send a velocity to the robot " 493 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
498 ptuFrameInterface = PTU_CAMERA_FRAME;
500 vpERROR_TRACE(
"Bad dimension fo speed vector in camera frame");
507 ptuFrameInterface = PTU_ARTICULAR_FRAME;
509 vpERROR_TRACE(
"Bad dimension fo speed vector in articular frame");
511 "in articular frame");
517 "in the reference frame: " 518 "functionality not implemented");
520 "in the reference frame:" 521 "functionality not implemented");
525 "in the mixt frame: " 526 "functionality not implemented");
529 "functionality not implemented");
533 "Case not taken in account.");
539 double ptuSpeedInterface[2];
546 for (
unsigned int i = 0; i < 2; ++i)
548 if (fabs(v[i]) > max) {
559 for (
unsigned int i = 0; i < 2; ++i)
560 ptuSpeedInterface[i] = v[i] * max;
569 vpCDEBUG(12) <<
"v: " << ptuSpeedInterface[0] <<
" " << ptuSpeedInterface[1] << std::endl;
570 ptu.move(ptuSpeedInterface, ptuFrameInterface);
595 TPtuFrame ptuFrameInterface = PTU_ARTICULAR_FRAME;
600 "functionality not implemented");
602 "functionality not implemented");
605 ptuFrameInterface = PTU_ARTICULAR_FRAME;
609 vpERROR_TRACE(
"Cannot get a velocity in the reference frame: " 610 "functionality not implemented");
612 "functionality not implemented");
617 "functionality not implemented");
619 "functionality not implemented");
624 double ptuSpeedInterface[2];
626 ptu.getCurrentSpeed(ptuSpeedInterface, ptuFrameInterface);
628 q_dot[0] = ptuSpeedInterface[0];
629 q_dot[1] = ptuSpeedInterface[1];
672 std::ifstream fd(filename.c_str(), std::ios::in);
679 std::string key(
"R:");
680 std::string id(
"#PTU-EVI - Position");
681 bool pos_found =
false;
686 while (std::getline(fd, line)) {
689 if (!(line.compare(0,
id.size(), id) == 0)) {
690 std::cout <<
"Error: this position file " << filename <<
" is not for Ptu-46 robot" << std::endl;
694 if ((line.compare(0, 1,
"#") == 0)) {
697 if ((line.compare(0, key.size(), key) == 0)) {
705 std::istringstream ss(line);
721 std::cout <<
"Error: unable to find a position for Ptu-46 robot in " << filename << std::endl;
754 ptu.measureDpl(d_, PTU_CAMERA_FRAME);
764 ptu.measureDpl(d_, PTU_ARTICULAR_FRAME);
771 vpERROR_TRACE(
"Cannot get a displacement in the reference frame: " 772 "functionality not implemented");
774 "functionality not implemented");
777 vpERROR_TRACE(
"Cannot get a displacement in the mixt frame: " 778 "functionality not implemented");
780 "functionality not implemented");
785 #elif !defined(VISP_BUILD_SHARED_LIBS) 788 void dummy_vpRobotPtu46(){};
Implementation of a matrix and operations on matrices.
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)
Implementation of an homogeneous matrix and operations on such kind of matrices.
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)
double maxRotationVelocity
Initialize the position controller.
void getDisplacement(vpRobot::vpControlFrameType frame, vpColVector &q)
unsigned int getRows() const
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_cVe(vpVelocityTwistMatrix &_cVe) const
Initialize the velocity controller.
static const unsigned int ndof
virtual vpRobotStateType getRobotState(void) const
virtual ~vpRobotPtu46(void)
vpVelocityTwistMatrix buildFrom(const vpTranslationVector &t, const vpRotationMatrix &R)
void get_eJe(vpMatrix &_eJe)
double getPositioningVelocity(void)
vpMatrix eJe
robot Jacobian expressed in the end-effector frame
void get_eJe(const vpColVector &q, vpMatrix &eJe) const
Implementation of column vector and the associated operations.
void get_cMe(vpHomogeneousMatrix &_cMe) const
bool readPositionFile(const std::string &filename, vpColVector &q)
vpMatrix fJe
robot Jacobian expressed in the robot reference frame available
void get_fJe(const vpColVector &q, vpMatrix &fJe) const
void setPositioningVelocity(const double velocity)
void resize(const unsigned int i, const bool flagNullify=true)