Fawkes API  Fawkes Development Version
motion_thread.h
1 
2 /***************************************************************************
3  * motion_thread.h - Provide NaoQi motion to Fawkes
4  *
5  * Created: Thu Jun 09 12:56:42 2011
6  * Copyright 2006-2011 Tim Niemueller [www.niemueller.de]
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_NAO_MOTION_THREAD_H_
24 #define __PLUGINS_NAO_MOTION_THREAD_H_
25 
26 #include <core/threading/thread.h>
27 #include <aspect/clock.h>
28 #include <aspect/logging.h>
29 #include <aspect/configurable.h>
30 #include <aspect/blackboard.h>
31 #include <aspect/blocked_timing.h>
32 #include <plugins/nao/aspect/naoqi.h>
33 
34 #include <vector>
35 
36 namespace AL {
37  class ALMotionProxy;
38  class ALTask;
39 }
40 namespace fawkes {
41  class HumanoidMotionInterface;
42  class NaoSensorInterface;
43 }
44 
46 : public fawkes::Thread,
47  public fawkes::LoggingAspect,
49  public fawkes::ClockAspect,
52  public fawkes::NaoQiAspect
53 {
54  public:
56  virtual ~NaoQiMotionThread();
57 
58  virtual void init();
59  virtual void loop();
60  virtual void finalize();
61 
62  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
63  protected: virtual void run() { Thread::run(); }
64 
65  private:
66  void stop_motion();
67  void process_messages();
68  void fix_angles();
69 
70  void goto_body_angles(float head_yaw, float head_pitch,
71  float l_shoulder_pitch, float l_shoulder_roll,
72  float l_elbow_yaw, float l_elbow_roll,
73  float l_wrist_yaw, float l_hand,
74  float l_hip_yaw_pitch, float l_hip_roll,
75  float l_hip_pitch, float l_knee_pitch,
76  float l_ankle_pitch, float l_ankle_roll,
77  float r_shoulder_pitch, float r_shoulder_roll,
78  float r_elbow_yaw, float r_elbow_roll,
79  float r_wrist_yaw, float r_hand,
80  float r_hip_yaw_pitch, float r_hip_roll,
81  float r_hip_pitch, float r_knee_pitch,
82  float r_ankle_pitch, float r_ankle_roll,
83  float time_sec);
84 
85 
86  private:
87  AL::ALPtr<AL::ALMotionProxy> __almotion;
88  AL::ALPtr<AL::ALThreadPool> __thread_pool;
89 
91  fawkes::NaoSensorInterface *__sensor_if;
92 
93  int __motion_task_id;
94  int __head_task_id;
95  AL::ALPtr<AL::ALTask> __motion_task;
96 };
97 
98 #endif
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:36
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: motion_thread.h:63
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
NaoSensorInterface Fawkes BlackBoard Interface.
Thread to provide NaoQi motions to Fawkes.
Definition: motion_thread.h:45
Thread aspect to use blocked timing.
HumanoidMotionInterface Fawkes BlackBoard Interface.
Thread aspect to log output.
Definition: logging.h:35
Thread aspect to get access to NaoQi broker.
Definition: naoqi.h:36
Thread aspect to access configuration data.
Definition: configurable.h:35