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 <core/threading/thread.h>
29 #include <aspect/logging.h>
30 #include <aspect/configurable.h>
31 #include <aspect/blackboard.h>
32 
33 #include <string>
34 #include <vector>
35 
36 namespace fawkes {
37  class Mutex;
38 }
39 
41 : public fawkes::Thread,
42  public fawkes::LoggingAspect,
45 {
46  public:
47  JacoGotoThread(const char *name, fawkes::jaco_arm_t* arm);
48  virtual ~JacoGotoThread();
49 
50  virtual void init();
51  virtual void finalize();
52  virtual void loop();
53 
54  virtual bool final();
55 
56  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);
57  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);
58  virtual void move_gripper(float f1, float f2, float f3);
59 
60  virtual void pos_ready();
61  virtual void pos_retract();
62 
63  virtual void stop();
64 
65  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
66  protected: virtual void run() { Thread::run(); }
67 
68  private:
69  void _goto_target();
70  void _exec_trajec(fawkes::jaco_trajec_t* trajec);
71 
72  fawkes::jaco_arm_t *__arm;
73  fawkes::Mutex *__final_mutex;
74 
76  float __finger_last[4]; // 3 positions + 1 counter
77 
78  bool __final;
79 
80  unsigned int __wait_status_check;
81 
82  void _check_final();
83 };
84 
85 
86 #endif
Jaco struct containing all components required for one arm.
Definition: types.h:95
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
JacoGotoThread(const char *name, fawkes::jaco_arm_t *arm)
Constructor.
Definition: goto_thread.cpp:46
Fawkes library namespace.
virtual void init()
Initialize.
Definition: goto_thread.cpp:65
virtual void pos_retract()
Moves the arm to the "RETRACT" position.
Thread class encapsulation of pthreads.
Definition: thread.h:42
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.
std::vector< jaco_trajec_point_t > jaco_trajec_t
A trajectory.
Definition: types.h:51
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: goto_thread.h:66
virtual ~JacoGotoThread()
Destructor.
Definition: goto_thread.cpp:59
virtual void pos_ready()
Moves the arm to the "READY" position.
virtual void stop()
Stops the current movement.
virtual void finalize()
Finalize.
Definition: goto_thread.cpp:72
const char * name() const
Get name of thread.
Definition: thread.h:95
Thread aspect to log output.
Definition: logging.h:35
virtual void move_gripper(float f1, float f2, float f3)
Moves only the gripper.
Thread aspect to access configuration data.
Definition: configurable.h:35
Jaco Arm movement thread.
Definition: goto_thread.h:40
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:49
virtual void loop()
The main loop of this thread.
Mutex mutual exclusion lock.
Definition: mutex.h:32
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...