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 <aspect/blackboard.h>
27 #include <aspect/blocked_timing.h>
28 #include <aspect/clock.h>
29 #include <aspect/configurable.h>
30 #include <aspect/logging.h>
31 #include <core/threading/thread.h>
32 #include <plugins/nao/aspect/naoqi.h>
33 
34 #include <vector>
35 
36 namespace AL {
37 class ALMotionProxy;
38 class ALTask;
39 } // namespace AL
40 namespace fawkes {
41 class HumanoidMotionInterface;
42 class NaoSensorInterface;
43 } // namespace fawkes
44 
46  public fawkes::LoggingAspect,
48  public fawkes::ClockAspect,
51  public fawkes::NaoQiAspect
52 {
53 public:
55  virtual ~NaoQiMotionThread();
56 
57  virtual void init();
58  virtual void loop();
59  virtual void finalize();
60 
61  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
62 protected:
63  virtual void
64  run()
65  {
66  Thread::run();
67  }
68 
69 private:
70  void stop_motion();
71  void process_messages();
72  void fix_angles();
73 
74  void goto_body_angles(float head_yaw,
75  float head_pitch,
76  float l_shoulder_pitch,
77  float l_shoulder_roll,
78  float l_elbow_yaw,
79  float l_elbow_roll,
80  float l_wrist_yaw,
81  float l_hand,
82  float l_hip_yaw_pitch,
83  float l_hip_roll,
84  float l_hip_pitch,
85  float l_knee_pitch,
86  float l_ankle_pitch,
87  float l_ankle_roll,
88  float r_shoulder_pitch,
89  float r_shoulder_roll,
90  float r_elbow_yaw,
91  float r_elbow_roll,
92  float r_wrist_yaw,
93  float r_hand,
94  float r_hip_yaw_pitch,
95  float r_hip_roll,
96  float r_hip_pitch,
97  float r_knee_pitch,
98  float r_ankle_pitch,
99  float r_ankle_roll,
100  float time_sec);
101 
102 private:
103  AL::ALPtr<AL::ALMotionProxy> almotion_;
104  AL::ALPtr<AL::ALThreadPool> thread_pool_;
105 
107  fawkes::NaoSensorInterface * sensor_if_;
108 
109  int motion_task_id_;
110  int head_task_id_;
111  AL::ALPtr<AL::ALTask> motion_task_;
112 };
113 
114 #endif
NaoQiMotionThread::NaoQiMotionThread
NaoQiMotionThread()
Constructor.
Definition: motion_thread.cpp:47
fawkes::NaoSensorInterface
NaoSensorInterface Fawkes BlackBoard Interface.
Definition: NaoSensorInterface.h:34
NaoQiMotionThread
Thread to provide NaoQi motions to Fawkes.
Definition: motion_thread.h:52
fawkes::NaoQiAspect
Thread aspect to get access to NaoQi broker.
Definition: naoqi.h:36
fawkes::BlockedTimingAspect
Thread aspect to use blocked timing.
Definition: blocked_timing.h:51
NaoQiMotionThread::init
virtual void init()
Initialize the thread.
Definition: motion_thread.cpp:59
NaoQiMotionThread::loop
virtual void loop()
Code to execute in the thread.
Definition: motion_thread.cpp:123
NaoQiMotionThread::finalize
virtual void finalize()
Finalize the thread.
Definition: motion_thread.cpp:83
fawkes::BlackBoardAspect
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
fawkes::HumanoidMotionInterface
HumanoidMotionInterface Fawkes BlackBoard Interface.
Definition: HumanoidMotionInterface.h:34
fawkes
Fawkes library namespace.
fawkes::LoggingAspect
Thread aspect to log output.
Definition: logging.h:33
fawkes::Thread
Thread class encapsulation of pthreads.
Definition: thread.h:46
fawkes::ConfigurableAspect
Thread aspect to access configuration data.
Definition: configurable.h:33
NaoQiMotionThread::run
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: motion_thread.h:64
fawkes::ClockAspect
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
NaoQiMotionThread::~NaoQiMotionThread
virtual ~NaoQiMotionThread()
Destructor.
Definition: motion_thread.cpp:54