Fawkes API  Fawkes Development Version
dcm_thread.h
1 
2 /***************************************************************************
3  * dcm_thread.h - Provide NaoQi DCM to Fawkes
4  *
5  * Created: Tue May 31 14:59:30 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_DCM_THREAD_H_
24 #define __PLUGINS_NAO_DCM_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 <core/utils/lock_vector.h>
35 
36 #include <interfaces/NaoJointPositionInterface.h>
37 #include <interfaces/NaoSensorInterface.h>
38 
39 #include <althread/alprocesssignals.h>
40 #include <alcommon/alproxy.h>
41 
42 #include <vector>
43 
44 namespace AL {
45  class ALMemoryFastAccess;
46 }
47 namespace fawkes {
48  class NaoJointStiffnessInterface;
49 }
50 
52 : public fawkes::Thread,
53  public fawkes::LoggingAspect,
56  public fawkes::ClockAspect,
58  public fawkes::NaoQiAspect
59 {
60  public:
62  virtual ~NaoQiDCMThread();
63 
64  virtual void init();
65  virtual void loop();
66  virtual void finalize();
67 
68  /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
69  protected: virtual void run() { Thread::run(); }
70 
71  private:
72  void dcm_callback();
73  void read_values();
74  void update_interfaces(fawkes::NaoJointPositionInterface *joint_pos_if,
75  fawkes::NaoJointStiffnessInterface *joint_stiffness_if,
76  fawkes::NaoSensorInterface *sensor_if);
77  void process_messages();
78  std::vector<std::string> parse_servo_bitfield(unsigned int servos);
79 
80 
81  void send_commands(unsigned int servos, std::string what,
82  float value, int time_offset);
83  void send_command(std::string name, float value,
84  std::string kind, int time_offset);
85 
86  int ultrasonic_value(fawkes::NaoSensorInterface::UltrasonicDirection direction);
87 
88  class HighFreqThread;
89  HighFreqThread *__highfreq_thread;
90 
91  private:
92  AL::ALPtr<AL::DCMProxy> __dcm;
93  AL::ALPtr<AL::ALMotionProxy> __almotion;
94  AL::ALPtr<AL::ALMemoryFastAccess> __memfa;
95  bool __robocup_version;
96 
97  AL::ALProcessSignals::ProcessSignalConnection __dcm_sigconn;
98 
99  int __dcm_time;
100  fawkes::LockVector<float> __values;
101 
102  fawkes::NaoJointPositionInterface *__joint_pos_highfreq_if;
103  fawkes::NaoJointPositionInterface *__joint_pos_if;
104  fawkes::NaoJointStiffnessInterface *__joint_stiffness_highfreq_if;
105  fawkes::NaoJointStiffnessInterface *__joint_stiffness_if;
106  fawkes::NaoSensorInterface *__sensor_highfreq_if;
107  fawkes::NaoSensorInterface *__sensor_if;
108 
109  uint8_t __robot_version[4];
111  int __usboard_version;
112 
113  AL::ALValue __alljoint_names;
114 };
115 
116 #endif
NaoJointPositionInterface Fawkes BlackBoard Interface.
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
Fawkes library namespace.
Thread class encapsulation of pthreads.
Definition: thread.h:42
NaoSensorInterface Fawkes BlackBoard Interface.
NaoJointStiffnessInterface Fawkes BlackBoard Interface.
Thread aspect to use blocked timing.
UltrasonicDirection
This determines the chosen sender/receiver.
Thread to provide DCM to Fawkes.
Definition: dcm_thread.h:51
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
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: dcm_thread.h:69
Thread to write data at full DCM frequency.
Definition: dcm_thread.cpp:125
RobotType
Enumeration describing the actual version of the robot that&#39;s being used.