Fawkes API  Fawkes Development Version
goto_thread.h
1 
2 /***************************************************************************
3  * goto_thread.h - Kinova Jaco plugin movement thread
4  *
5  * Created: Thu Jun 20 15:04:20 2013
6  * Copyright 2013 Bahram Maleki-Fard
7  *
8  ****************************************************************************/
9 
10 /* This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL file in the doc directory.
21  */
22 
23 #ifndef _PLUGINS_JACO_GOTO_THREAD_H_
24 #define _PLUGINS_JACO_GOTO_THREAD_H_
25 
26 #include "types.h"
27 
28 #include <aspect/blackboard.h>
29 #include <aspect/configurable.h>
30 #include <aspect/logging.h>
31 #include <core/threading/thread.h>
32 
33 #include <string>
34 #include <vector>
35 
36 namespace fawkes {
37 class Mutex;
38 }
39 
41  public fawkes::LoggingAspect,
44 {
45 public:
46  JacoGotoThread(const char *name, fawkes::jaco_arm_t *arm);
47  virtual ~JacoGotoThread();
48 
49  virtual void init();
50  virtual void finalize();
51  virtual void loop();
52 
53  virtual bool final();
54 
55  virtual void set_target(float x,
56  float y,
57  float z,
58  float e1,
59  float e2,
60  float e3,
61  float f1 = 0.f,
62  float f2 = 0.f,
63  float f3 = 0.f);
64  virtual void set_target_ang(float j1,
65  float j2,
66  float j3,
67  float j4,
68  float j5,
69  float j6,
70  float f1 = 0.f,
71  float f2 = 0.f,
72  float f3 = 0.f);
73  virtual void move_gripper(float f1, float f2, float f3);
74 
75  virtual void pos_ready();
76  virtual void pos_retract();
77 
78  virtual void stop();
79 
80  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
81 protected:
82  virtual void
83  run()
84  {
85  Thread::run();
86  }
87 
88 private:
89  void _goto_target();
90  void _exec_trajec(fawkes::jaco_trajec_t *trajec);
91 
92  fawkes::jaco_arm_t *arm_;
93  fawkes::Mutex * final_mutex_;
94 
96  float finger_last_[4]; // 3 positions + 1 counter
97 
98  bool final_;
99 
100  unsigned int wait_status_check_;
101 
102  void _check_final();
103 };
104 
105 #endif
Jaco Arm movement thread.
Definition: goto_thread.h:44
virtual void loop()
The main loop of this thread.
virtual void finalize()
Finalize.
Definition: goto_thread.cpp:72
virtual void pos_retract()
Moves the arm to the "RETRACT" position.
virtual void set_target_ang(float j1, float j2, float j3, float j4, float j5, float j6, float f1=0.f, float f2=0.f, float f3=0.f)
Set new target, given joint positions This target is added to the queue, skipping trajectory planning...
JacoGotoThread(const char *name, fawkes::jaco_arm_t *arm)
Constructor.
Definition: goto_thread.cpp:47
virtual void init()
Initialize.
Definition: goto_thread.cpp:65
virtual void set_target(float x, float y, float z, float e1, float e2, float e3, float f1=0.f, float f2=0.f, float f3=0.f)
Set new target, given cartesian coordinates.
virtual void stop()
Stops the current movement.
virtual void pos_ready()
Moves the arm to the "READY" position.
virtual void move_gripper(float f1, float f2, float f3)
Moves only the gripper.
virtual ~JacoGotoThread()
Destructor.
Definition: goto_thread.cpp:59
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: goto_thread.h:83
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Mutex mutual exclusion lock.
Definition: mutex.h:33
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:50
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.
std::vector< jaco_trajec_point_t > jaco_trajec_t
A trajectory.
Definition: types.h:48
Jaco struct containing all components required for one arm.
Definition: types.h:93