Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * motion_thread.h - Provide NaoQi motion to Fawkes 00004 * 00005 * Created: Thu Jun 09 12:56:42 2011 00006 * Copyright 2006-2011 Tim Niemueller [www.niemueller.de] 00007 * 00008 ****************************************************************************/ 00009 00010 /* This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL file in the doc directory. 00021 */ 00022 00023 #ifndef __PLUGINS_NAO_MOTION_THREAD_H_ 00024 #define __PLUGINS_NAO_MOTION_THREAD_H_ 00025 00026 #include <core/threading/thread.h> 00027 #include <aspect/clock.h> 00028 #include <aspect/logging.h> 00029 #include <aspect/configurable.h> 00030 #include <aspect/blackboard.h> 00031 #include <aspect/blocked_timing.h> 00032 #include <plugins/nao/aspect/naoqi.h> 00033 00034 #include <vector> 00035 00036 namespace AL { 00037 class ALMotionProxy; 00038 class ALTask; 00039 } 00040 namespace fawkes { 00041 class HumanoidMotionInterface; 00042 class NaoSensorInterface; 00043 } 00044 00045 class NaoQiMotionThread 00046 : public fawkes::Thread, 00047 public fawkes::LoggingAspect, 00048 public fawkes::ConfigurableAspect, 00049 public fawkes::ClockAspect, 00050 public fawkes::BlackBoardAspect, 00051 public fawkes::BlockedTimingAspect, 00052 public fawkes::NaoQiAspect 00053 { 00054 public: 00055 NaoQiMotionThread(); 00056 virtual ~NaoQiMotionThread(); 00057 00058 virtual void init(); 00059 virtual void loop(); 00060 virtual void finalize(); 00061 00062 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */ 00063 protected: virtual void run() { Thread::run(); } 00064 00065 private: 00066 void stop_motion(); 00067 void process_messages(); 00068 void fix_angles(); 00069 00070 void goto_body_angles(float head_yaw, float head_pitch, 00071 float l_shoulder_pitch, float l_shoulder_roll, 00072 float l_elbow_yaw, float l_elbow_roll, 00073 float l_wrist_yaw, float l_hand, 00074 float l_hip_yaw_pitch, float l_hip_roll, 00075 float l_hip_pitch, float l_knee_pitch, 00076 float l_ankle_pitch, float l_ankle_roll, 00077 float r_shoulder_pitch, float r_shoulder_roll, 00078 float r_elbow_yaw, float r_elbow_roll, 00079 float r_wrist_yaw, float r_hand, 00080 float r_hip_yaw_pitch, float r_hip_roll, 00081 float r_hip_pitch, float r_knee_pitch, 00082 float r_ankle_pitch, float r_ankle_roll, 00083 float time_sec); 00084 00085 00086 private: 00087 AL::ALPtr<AL::ALMotionProxy> __almotion; 00088 AL::ALPtr<AL::ALThreadPool> __thread_pool; 00089 00090 fawkes::HumanoidMotionInterface *__hummot_if; 00091 fawkes::NaoSensorInterface *__sensor_if; 00092 00093 int __motion_task_id; 00094 int __head_task_id; 00095 AL::ALPtr<AL::ALTask> __motion_task; 00096 }; 00097 00098 #endif