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 
40 class JacoGotoThread : public fawkes::Thread,
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
JacoGotoThread::move_gripper
virtual void move_gripper(float f1, float f2, float f3)
Moves only the gripper.
Definition: goto_thread.cpp:242
JacoGotoThread::set_target_ang
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...
Definition: goto_thread.cpp:176
fawkes::Mutex
Definition: mutex.h:36
JacoGotoThread::stop
virtual void stop()
Stops the current movement.
Definition: goto_thread.cpp:260
JacoGotoThread
Definition: goto_thread.h:39
JacoGotoThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: goto_thread.h:82
fawkes::RefPtr
RefPtr<> is a reference-counting shared smartpointer.
Definition: refptr.h:55
JacoGotoThread::init
virtual void init()
Initialize.
Definition: goto_thread.cpp:64
fawkes::Thread::name
const char * name() const
Definition: thread.h:99
JacoGotoThread::pos_ready
virtual void pos_ready()
Moves the arm to the "READY" position.
Definition: goto_thread.cpp:213
JacoGotoThread::set_target
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.
Definition: goto_thread.cpp:129
fawkes::BlackBoardAspect
Definition: blackboard.h:36
fawkes
fawkes::LoggingAspect
Definition: logging.h:36
JacoGotoThread::finalize
virtual void finalize()
Finalize.
Definition: goto_thread.cpp:71
fawkes::jaco_trajec_t
std::vector< jaco_trajec_point_t > jaco_trajec_t
A trajectory.
Definition: types.h:47
JacoGotoThread::pos_retract
virtual void pos_retract()
Moves the arm to the "RETRACT" position.
Definition: goto_thread.cpp:227
JacoGotoThread::JacoGotoThread
JacoGotoThread(const char *name, fawkes::jaco_arm_t *arm)
Constructor.
Definition: goto_thread.cpp:46
JacoGotoThread::~JacoGotoThread
virtual ~JacoGotoThread()
Destructor.
Definition: goto_thread.cpp:58
fawkes::Thread
Definition: thread.h:44
fawkes::jaco_arm_struct
Jaco struct containing all components required for one arm.
Definition: types.h:91
fawkes::ConfigurableAspect
Definition: configurable.h:36
JacoGotoThread::loop
virtual void loop()
The main loop of this thread.
Definition: goto_thread.cpp:287