Visual Servoing Platform  version 3.6.1 under development (2024-11-14)
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 
60 BEGIN_VISP_NAMESPACE
91 class VISP_EXPORT vpRobotBiclops : public vpBiclops, public vpRobot
92 {
93 public:
94  static const double defaultPositioningVelocity;
95 
131  vpRobotBiclops();
132 
165  VP_EXPLICIT vpRobotBiclops(const std::string &filename);
166 
171  virtual ~vpRobotBiclops();
172 
180  void init() VP_OVERRIDE;
181 
189  void get_cMe(vpHomogeneousMatrix &cMe) const;
190 
199  void get_cVe(vpVelocityTwistMatrix &cVe) const;
200 
210  void get_eJe(vpMatrix &eJe) VP_OVERRIDE;
211 
218  void get_fJe(vpMatrix &fJe) VP_OVERRIDE;
219 
240  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &d) VP_OVERRIDE;
241 
255  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) VP_OVERRIDE;
256 
263  double getPositioningVelocity(void);
264 
275  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q_dot);
276 
287  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
288 
306  bool readPositionFile(const std::string &filename, vpColVector &q);
307 
311  void setConfigFile(const std::string &filename = "/usr/share/BiclopsDefault.cfg");
312 
327  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) VP_OVERRIDE;
328 
344  void setPosition(const vpRobot::vpControlFrameType frame, const double &q1, const double &q2);
345 
357  void setPosition(const std::string &filename);
358 
365  void setPositioningVelocity(double velocity);
366 
371  vpRobot::vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState) VP_OVERRIDE;
372 
397  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot) VP_OVERRIDE;
398 
402  void stopMotion();
403 
404  /*
405  * Control loop to manage the Biclops joint limits in speed control.
406  *
407  * This control loop is running in a separate thread in order to detect each 5
408  * ms joint limits during the speed control. If a joint limit is detected the
409  * axis should be halted.
410  *
411  * \warning Velocity control mode is not exported from the top-level Biclops
412  * API class provided by Traclabs. That means that there is no protection in
413  * this mode to prevent an axis from striking its hard limit. In position mode,
414  * Traclabs put soft limits in that keep any command from driving to a position
415  * too close to the hard limits. In velocity mode this protection does not
416  * exist in the current API.
417  *
418  * \warning With the understanding that hitting the hard limits at full
419  * speed/power can damage the unit, damage due to velocity mode commanding is
420  * under user responsibility.
421  */
422  static void vpRobotBiclopsSpeedControlLoop(void *arg);
423 
424 private:
425  std::thread m_control_thread;
426 
427  std::string m_configfile; // Biclops config file
428 
429  class vpRobotBiclopsController;
430  vpRobotBiclopsController *m_controller;
431 
432  double m_positioningVelocity;
433  vpColVector m_q_previous;
434 
435  // private:
436  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
437  // /*! \brief No copy constructor allowed. */
438  // vpRobotBiclops(const vpRobotBiclops &)
439  // : vpBiclops(), vpRobot(), m_control_thread(), m_controller(),
440  // m_positioningVelocity(0), m_q_previous()
441  // {
442  // throw vpException(vpException::functionNotImplementedError, "Not
443  // implemented!");
444  // }
445  // vpRobotBiclops &operator=(const vpRobotBiclops &){
446  // throw vpException(vpException::functionNotImplementedError, "Not
447  // implemented!"); return *this;
448  // }
449  //#endif
450 };
451 END_VISP_NAMESPACE
452 #endif /* #ifndef _vpRobotBiclops_h_ */
453 
454 #endif
Jacobian, geometric model functionalities... for Biclops, pan, tilt head.
Definition: vpBiclops.h:64
void init(void)
Definition: vpBiclops.cpp:169
Implementation of column vector and the associated operations.
Definition: vpColVector.h:191
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:169
Interface for the Biclops, pan, tilt head control.
static const double defaultPositioningVelocity
Class that defines a generic virtual robot.
Definition: vpRobot.h:59
vpControlFrameType
Definition: vpRobot.h:77
vpRobotStateType
Definition: vpRobot.h:65