37#include <visp3/core/vpConfig.h>
41#include <visp3/core/vpDebug.h>
42#include <visp3/core/vpIoTools.h>
43#include <visp3/robot/vpPtu46.h>
44#include <visp3/robot/vpRobotException.h>
45#include <visp3/robot/vpRobotPtu46.h>
52bool vpRobotPtu46::robotAlreadyCreated =
false;
68vpRobotPtu46::vpRobotPtu46(
const std::string &device) :
vpRobot()
70 this->device = device;
107 if (0 != ptu.close()) {
108 vpERROR_TRACE(
"Error while closing communications with the robot ptu-46.");
111 vpRobotPtu46::robotAlreadyCreated =
false;
135 if (0 != ptu.init(device.c_str())) {
303 "Modification of the robot state");
334 if (0 != ptu.move(artpos, positioningVelocity, PTU_ABSOLUTE_MODE)) {
436 if (0 != ptu.getCurrentPosition(artpos)) {
437 vpERROR_TRACE(
"Error when calling vpRobotPtu46::getPosition()");
479 TPtuFrame ptuFrameInterface;
483 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
485 "Cannot send a velocity to the robot "
486 "use setRobotState(vpRobot::STATE_VELOCITY_CONTROL) first) ");
491 ptuFrameInterface = PTU_CAMERA_FRAME;
492 if (v.getRows() != 2) {
493 vpERROR_TRACE(
"Bad dimension fo speed vector in camera frame");
500 ptuFrameInterface = PTU_ARTICULAR_FRAME;
501 if (v.getRows() != 2) {
503 "in articular frame");
509 "in the reference frame:"
510 "functionality not implemented");
515 "functionality not implemented");
519 "in the end-effector frame:"
520 "functionality not implemented");
528 double ptuSpeedInterface[2];
535 for (
unsigned int i = 0; i < 2; ++i)
537 if (fabs(v[i]) > max) {
548 for (
unsigned int i = 0; i < 2; ++i)
549 ptuSpeedInterface[i] = v[i] * max;
558 vpCDEBUG(12) <<
"v: " << ptuSpeedInterface[0] <<
" " << ptuSpeedInterface[1] << std::endl;
559 ptu.move(ptuSpeedInterface, ptuFrameInterface);
584 TPtuFrame ptuFrameInterface = PTU_ARTICULAR_FRAME;
589 "functionality not implemented");
592 ptuFrameInterface = PTU_ARTICULAR_FRAME;
597 "functionality not implemented");
601 "functionality not implemented");
605 "functionality not implemented");
610 double ptuSpeedInterface[2];
612 ptu.getCurrentSpeed(ptuSpeedInterface, ptuFrameInterface);
614 q_dot[0] = ptuSpeedInterface[0];
615 q_dot[1] = ptuSpeedInterface[1];
658 std::ifstream fd(filename.c_str(), std::ios::in);
665 std::string key(
"R:");
666 std::string id(
"#PTU-EVI - Position");
667 bool pos_found =
false;
672 while (std::getline(fd, line)) {
675 if (!(line.compare(0,
id.size(),
id) == 0)) {
676 std::cout <<
"Error: this position file " << filename <<
" is not for Ptu-46 robot" << std::endl;
680 if ((line.compare(0, 1,
"#") == 0)) {
683 if ((line.compare(0, key.size(), key) == 0)) {
691 std::istringstream ss(line);
707 std::cout <<
"Error: unable to find a position for Ptu-46 robot in " << filename << std::endl;
740 ptu.measureDpl(d_, PTU_CAMERA_FRAME);
750 ptu.measureDpl(d_, PTU_ARTICULAR_FRAME);
758 "functionality not implemented");
762 "functionality not implemented");
766 "functionality not implemented");
771#elif !defined(VISP_BUILD_SHARED_LIBS)
773void dummy_vpRobotPtu46() { }
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)
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)