Visual Servoing Platform  version 3.6.1 under development (2024-03-29)
vpRobotBiclops.h
1 /*
2  * ViSP, open source Visual Servoing Platform software.
3  * Copyright (C) 2005 - 2023 by Inria. All rights reserved.
4  *
5  * This software is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  * See the file LICENSE.txt at the root directory of this source
10  * distribution for additional information about the GNU GPL.
11  *
12  * For using ViSP with software that can not be combined with the GNU
13  * GPL, please contact Inria about acquiring a ViSP Professional
14  * Edition License.
15  *
16  * See https://visp.inria.fr for more information.
17  *
18  * This software was developed at:
19  * Inria Rennes - Bretagne Atlantique
20  * Campus Universitaire de Beaulieu
21  * 35042 Rennes Cedex
22  * France
23  *
24  * If you have questions regarding the use of this file, please contact
25  * Inria at visp@inria.fr
26  *
27  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29  *
30  * Description:
31  * Interface for the Biclops robot.
32  */
33 
34 #ifndef _vpRobotBiclops_h_
35 #define _vpRobotBiclops_h_
36 
37 #include <visp3/core/vpConfig.h>
38 
39 #if defined(VISP_HAVE_BICLOPS) && defined(VISP_HAVE_THREADS)
40 
41 /* ------------------------------------------------------------------------ */
42 /* --- INCLUDES ----------------------------------------------------------- */
43 /* ------------------------------------------------------------------------ */
44 
45 /* --- GENERAL --- */
46 #include <iostream>
47 #include <thread>
48 #include <stdio.h>
49 
50 /* --- ViSP --- */
51 #include <visp3/core/vpColVector.h>
52 #include <visp3/core/vpVelocityTwistMatrix.h>
53 #include <visp3/robot/vpBiclops.h>
54 #include <visp3/robot/vpRobot.h>
55 
56 /* ------------------------------------------------------------------------ */
57 /* --- CLASS -------------------------------------------------------------- */
58 /* ------------------------------------------------------------------------ */
59 
90 class VISP_EXPORT vpRobotBiclops : public vpBiclops, public vpRobot
91 {
92 public:
93  static const double defaultPositioningVelocity;
94 
126  vpRobotBiclops();
127 
156  explicit vpRobotBiclops(const std::string &filename);
157 
162  virtual ~vpRobotBiclops();
163 
171  void init() vp_override;
172 
180  void get_cMe(vpHomogeneousMatrix &cMe) const;
181 
190  void get_cVe(vpVelocityTwistMatrix &cVe) const;
191 
201  void get_eJe(vpMatrix &eJe) vp_override;
202 
209  void get_fJe(vpMatrix &fJe) vp_override;
210 
231  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &d) vp_override;
232 
246  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) vp_override;
247 
254  double getPositioningVelocity(void);
255 
266  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q_dot);
267 
278  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
279 
297  bool readPositionFile(const std::string &filename, vpColVector &q);
298 
302  void setConfigFile(const std::string &filename = "/usr/share/BiclopsDefault.cfg");
303 
318  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) vp_override;
319 
335  void setPosition(const vpRobot::vpControlFrameType frame, const double &q1, const double &q2);
336 
348  void setPosition(const std::string &filename);
349 
356  void setPositioningVelocity(double velocity);
357 
362  vpRobot::vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState) vp_override;
363 
388  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot) vp_override;
389 
393  void stopMotion();
394 
395  /*
396  * Control loop to manage the Biclops joint limits in speed control.
397  *
398  * This control loop is running in a separate thread in order to detect each 5
399  * ms joint limits during the speed control. If a joint limit is detected the
400  * axis should be halted.
401  *
402  * \warning Velocity control mode is not exported from the top-level Biclops
403  * API class provided by Traclabs. That means that there is no protection in
404  * this mode to prevent an axis from striking its hard limit. In position mode,
405  * Traclabs put soft limits in that keep any command from driving to a position
406  * too close to the hard limits. In velocity mode this protection does not
407  * exist in the current API.
408  *
409  * \warning With the understanding that hitting the hard limits at full
410  * speed/power can damage the unit, damage due to velocity mode commanding is
411  * under user responsibility.
412  */
413  static void vpRobotBiclopsSpeedControlLoop(void *arg);
414 
415 private:
416  std::thread m_control_thread;
417 
418  std::string m_configfile; // Biclops config file
419 
420  class vpRobotBiclopsController;
421  vpRobotBiclopsController *m_controller;
422 
423  double m_positioningVelocity;
424  vpColVector m_q_previous;
425 
426  // private:
427  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
428  // /*! \brief No copy constructor allowed. */
429  // vpRobotBiclops(const vpRobotBiclops &)
430  // : vpBiclops(), vpRobot(), m_control_thread(), m_controller(),
431  // m_positioningVelocity(0), m_q_previous()
432  // {
433  // throw vpException(vpException::functionNotImplementedError, "Not
434  // implemented!");
435  // }
436  // vpRobotBiclops &operator=(const vpRobotBiclops &){
437  // throw vpException(vpException::functionNotImplementedError, "Not
438  // implemented!"); return *this;
439  // }
440  //#endif
441 };
442 
443 #endif /* #ifndef _vpRobotBiclops_h_ */
444 
445 #endif
Jacobian, geometric model functionalities... for Biclops, pan, tilt head.
Definition: vpBiclops.h:62
void init(void)
Definition: vpBiclops.cpp:168
Implementation of column vector and the associated operations.
Definition: vpColVector.h:163
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:146
Interface for the Biclops, pan, tilt head control.
static const double defaultPositioningVelocity
Class that defines a generic virtual robot.
Definition: vpRobot.h:57
vpControlFrameType
Definition: vpRobot.h:75
vpRobotStateType
Definition: vpRobot.h:63