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/* This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU Library General Public License for more details.
18 *
19 * Read the full text in the LICENSE.GPL file in the doc directory.
20 */
21
22#ifndef _PLUGINS_NAO_DCM_THREAD_H_
23#define _PLUGINS_NAO_DCM_THREAD_H_
24
25#include <alcommon/alproxy.h>
26#include <althread/alprocesssignals.h>
27#include <aspect/blackboard.h>
28#include <aspect/blocked_timing.h>
29#include <aspect/clock.h>
30#include <aspect/configurable.h>
31#include <aspect/logging.h>
32#include <core/threading/thread.h>
33#include <core/utils/lock_vector.h>
34#include <interfaces/NaoJointPositionInterface.h>
35#include <interfaces/NaoSensorInterface.h>
36#include <plugins/nao/aspect/naoqi.h>
37
38#include <vector>
39
40namespace AL {
41class ALMemoryFastAccess;
42}
43namespace fawkes {
44class NaoJointStiffnessInterface;
45}
46
54{
55public:
57 virtual ~NaoQiDCMThread();
58
59 virtual void init();
60 virtual void loop();
61 virtual void finalize();
62
63 /** Stub to see name in backtrace for easier debugging. @see Thread::run() */
64protected:
65 virtual void
67 {
68 Thread::run();
69 }
70
71private:
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 void send_commands(unsigned int servos, const std::string &what, float value, int time_offset);
81 void send_command(const std::string &name, float value, const std::string &kind, int time_offset);
82
83 int ultrasonic_value(fawkes::NaoSensorInterface::UltrasonicDirection direction);
84
85 class HighFreqThread;
86 HighFreqThread *highfreq_thread_;
87
88private:
89 AL::ALPtr<AL::DCMProxy> dcm_;
90 AL::ALPtr<AL::ALMotionProxy> almotion_;
91 AL::ALPtr<AL::ALMemoryFastAccess> memfa_;
92 bool robocup_version_;
93
94 AL::ALProcessSignals::ProcessSignalConnection dcm_sigconn_;
95
96 int dcm_time_;
98
99 fawkes::NaoJointPositionInterface * joint_pos_highfreq_if_;
100 fawkes::NaoJointPositionInterface * joint_pos_if_;
101 fawkes::NaoJointStiffnessInterface *joint_stiffness_highfreq_if_;
102 fawkes::NaoJointStiffnessInterface *joint_stiffness_if_;
103 fawkes::NaoSensorInterface * sensor_highfreq_if_;
104 fawkes::NaoSensorInterface * sensor_if_;
105
106 uint8_t robot_version_[4];
108 int usboard_version_;
109
110 AL::ALValue alljoint_names_;
111};
112
113#endif
Thread to provide DCM to Fawkes.
Definition: dcm_thread.h:54
virtual void finalize()
Finalize the thread.
Definition: dcm_thread.cpp:543
virtual void init()
Initialize the thread.
Definition: dcm_thread.cpp:263
virtual ~NaoQiDCMThread()
Destructor.
Definition: dcm_thread.cpp:258
NaoQiDCMThread()
Constructor.
Definition: dcm_thread.cpp:251
virtual void loop()
Code to execute in the thread.
Definition: dcm_thread.cpp:578
virtual void run()
Stub to see name in backtrace for easier debugging.
Definition: dcm_thread.h:66
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect to use blocked timing.
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
NaoJointPositionInterface Fawkes BlackBoard Interface.
RobotType
Enumeration describing the actual version of the robot that's being used.
NaoJointStiffnessInterface Fawkes BlackBoard Interface.
Thread aspect to get access to NaoQi broker.
Definition: naoqi.h:36
NaoSensorInterface Fawkes BlackBoard Interface.
UltrasonicDirection
This determines the chosen sender/receiver.
Thread class encapsulation of pthreads.
Definition: thread.h:46
const char * name() const
Get name of thread.
Definition: thread.h:100
Fawkes library namespace.