Visual Servoing Platform  version 3.6.1 under development (2024-06-19)
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 
91 class VISP_EXPORT vpRobotBiclops : public vpBiclops, public vpRobot
92 {
93 public:
94  static const double defaultPositioningVelocity;
95 
127  vpRobotBiclops();
128 
157  explicit vpRobotBiclops(const std::string &filename);
158 
163  virtual ~vpRobotBiclops();
164 
172  void init() vp_override;
173 
181  void get_cMe(vpHomogeneousMatrix &cMe) const;
182 
191  void get_cVe(vpVelocityTwistMatrix &cVe) const;
192 
202  void get_eJe(vpMatrix &eJe) vp_override;
203 
210  void get_fJe(vpMatrix &fJe) vp_override;
211 
232  void getDisplacement(const vpRobot::vpControlFrameType frame, vpColVector &d) vp_override;
233 
247  void getPosition(const vpRobot::vpControlFrameType frame, vpColVector &q) vp_override;
248 
255  double getPositioningVelocity(void);
256 
267  void getVelocity(const vpRobot::vpControlFrameType frame, vpColVector &q_dot);
268 
279  vpColVector getVelocity(const vpRobot::vpControlFrameType frame);
280 
298  bool readPositionFile(const std::string &filename, vpColVector &q);
299 
303  void setConfigFile(const std::string &filename = "/usr/share/BiclopsDefault.cfg");
304 
319  void setPosition(const vpRobot::vpControlFrameType frame, const vpColVector &q) vp_override;
320 
336  void setPosition(const vpRobot::vpControlFrameType frame, const double &q1, const double &q2);
337 
349  void setPosition(const std::string &filename);
350 
357  void setPositioningVelocity(double velocity);
358 
363  vpRobot::vpRobotStateType setRobotState(const vpRobot::vpRobotStateType newState) vp_override;
364 
389  void setVelocity(const vpRobot::vpControlFrameType frame, const vpColVector &q_dot) vp_override;
390 
394  void stopMotion();
395 
396  /*
397  * Control loop to manage the Biclops joint limits in speed control.
398  *
399  * This control loop is running in a separate thread in order to detect each 5
400  * ms joint limits during the speed control. If a joint limit is detected the
401  * axis should be halted.
402  *
403  * \warning Velocity control mode is not exported from the top-level Biclops
404  * API class provided by Traclabs. That means that there is no protection in
405  * this mode to prevent an axis from striking its hard limit. In position mode,
406  * Traclabs put soft limits in that keep any command from driving to a position
407  * too close to the hard limits. In velocity mode this protection does not
408  * exist in the current API.
409  *
410  * \warning With the understanding that hitting the hard limits at full
411  * speed/power can damage the unit, damage due to velocity mode commanding is
412  * under user responsibility.
413  */
414  static void vpRobotBiclopsSpeedControlLoop(void *arg);
415 
416 private:
417  std::thread m_control_thread;
418 
419  std::string m_configfile; // Biclops config file
420 
421  class vpRobotBiclopsController;
422  vpRobotBiclopsController *m_controller;
423 
424  double m_positioningVelocity;
425  vpColVector m_q_previous;
426 
427  // private:
428  //#ifndef DOXYGEN_SHOULD_SKIP_THIS
429  // /*! \brief No copy constructor allowed. */
430  // vpRobotBiclops(const vpRobotBiclops &)
431  // : vpBiclops(), vpRobot(), m_control_thread(), m_controller(),
432  // m_positioningVelocity(0), m_q_previous()
433  // {
434  // throw vpException(vpException::functionNotImplementedError, "Not
435  // implemented!");
436  // }
437  // vpRobotBiclops &operator=(const vpRobotBiclops &){
438  // throw vpException(vpException::functionNotImplementedError, "Not
439  // implemented!"); return *this;
440  // }
441  //#endif
442 };
444 #endif /* #ifndef _vpRobotBiclops_h_ */
445 
446 #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:171
Implementation of an homogeneous matrix and operations on such kind of matrices.
Implementation of a matrix and operations on matrices.
Definition: vpMatrix.h:151
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