Main Page · Modules · All Classes · Class Hierarchy
MAHead.hpp
1 /*
2  * This file is part of the AiBO+ project
3  *
4  * Copyright (C) 2005-2016 Csaba Kertész (csaba.kertesz@gmail.com)
5  *
6  * AiBO+ is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * AiBO+ is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
19  *
20  */
21 
22 #pragma once
23 
24 #include "core/MANum.hpp"
25 #include "MARobotStateUpdater.hpp"
26 
27 #include <MCSamples.hpp>
28 
29 // It is a helper class to model the stroking over touch buttons
30 class MATouchButtonStroked
31 {
32 public:
33  explicit MATouchButtonStroked(unsigned int max_value);
34 
35  void PutValue(int value);
36  bool IsValid();
37  bool IsStroked();
38  bool IsJustStroked();
39 
40 private:
41  int MaxValue;
42  int CurrentValue;
43  MCSamples<int> Samples;
44  MCSamples<int> SamplesLong;
45 };
46 
55 struct MAHead : public MARobotStateUpdater
56 {
58  MAHead();
59 
60 private:
61  // Update the sensor indicators
62  virtual void UpdateRobotState(MARobotState& state) override;
63  void GenerateHeadPushedLeft(int cycle_time);
64  void GenerateHeadPushedRight(int cycle_time);
65  void GenerateCrownPressed(int cycle_time);
66  void GenerateCrownStroked(int cycle_time);
67  void GenerateChinStroked(int cycle_time);
68  void GenerateDaylightLevel(int cycle_time);
69  void GenerateSleptAwaken(int cycle_time);
70  void GenerateMouthStopped(int cycle_time);
71 
72 public:
97  /*
98  * The mouth is stopped
99  * 0 - Not stopped 100 - Stopped
100  */
101  MANum<int> MouthStopped;
102  /*
103  * Camera brightness level
104  * 0 - Darkness 100 - Full brightness
105  */
106  MANum<int> CameraBrightness;
107  /*
108  * Left-right direction of the head
109  * -100 - Left 100 - Right
110  */
111  MANum<int> LeftRight;
112  /*
113  * The chin on the head is pressed
114  * 0 - Not pressed 1 - Pressed
115  */
116  MANum<int> ChinButton;
117  /*
118  * The crown on the head is pressed
119  * 0 - Not pressed 35 - Fully pressed
120  */
121  MANum<int> CrownButton;
122  /*
123  * Fore-back direction of the head
124  * -100 - Back 100 - Fore
125  */
126  MANum<int> ForeBack;
127  /*
128  * Up-down direction of the head
129  * -100 - Down 100 - Up
130  */
131  MANum<int> UpDown;
132  /*
133  * The crown on the head is pressed
134  * 0 - Not pressed 100 - Pressed
135  */
136  MANum<int> CrownPressed;
137  /*
138  * The chin on the head is stroked
139  * 0 - Not stroked 100 - Stroked
140  */
141  MANum<int> ChinStroked;
142  /*
143  * The crown on the head is stroked
144  * 0 - Not stroked 100 - Stroked
145  */
146  MANum<int> CrownStroked;
147  /*
148  * The head is push from left
149  * 0 - Not pushed 100 - Pushed
150  */
151  MANum<int> PushedLeft;
152  /*
153  * The head is push from right
154  * 0 - Not pushed 100 - Pushed
155  */
156  MANum<int> PushedRight;
157  /*
158  * The daylight level of the environment
159  * 0 - Full darkness/Undefined 100 - Full daylight
160  */
161  MANum<int> DaylightLevel;
162  /*
163  * Probability of sleeping/awake state
164  * 0 - Slept 100 - Awaken
165  */
166  MANum<int> SleptAwaken;
167  /*
168  * Eye pupil size
169  * 1 - Smallest 5 - Largest
170  */
171  MANum<int> EyePupilSize;
172 private:
173  MAIntervalNum<int> HeadPushedLeftFactor;
174  MAIntervalNum<int> HeadPushedRightFactor;
175  MAIntervalNum<int> CrownPressedFactor;
176  MATouchButtonStroked CrownTouched;
177  MAIntervalNum<int> CrownStrokedFactor;
178  MAIntervalNum<int> ChinStrokedFactor;
179  MCSamples<int> ChinSamples;
180  MCSamples<int> BrightnessSamples;
181  MCSamples<int> BrightnessSamplesLong;
182  MAIntervalNum<int> SleptAwakenFactor;
183  MAIntervalNum<int> MouthStoppedFactor;
184 };
185 
MANum< int > MouthMoving
Whenever the mouth is moving.
Definition: MAHead.hpp:94
MANum< int > MouthForce
Force in the mouth joint.
Definition: MAHead.hpp:92
MANum< int > Tilt2
Second tilt joint degree (-20; 50)
Definition: MAHead.hpp:82
MANum< int > PanForce
Force in the pan joint.
Definition: MAHead.hpp:76
MANum< int > Tilt1Force
Force in the first tilt joint.
Definition: MAHead.hpp:80
MANum< int > Pan
Pan joint degree (-93; 93)
Definition: MAHead.hpp:74
MANum< int > Moving
Whenever the any head joint is moving.
Definition: MAHead.hpp:86
Robot state updater base class.
MANum< int > Mouth
Mouth joint degree (-60; -3)
Definition: MAHead.hpp:90
MANum< int > InMotion
Whenever the any head joint is in motion.
Definition: MAHead.hpp:88
MANum< int > MouthClosed
Whenever the mouth is closed.
Definition: MAHead.hpp:96
MANum< int > Tilt2Force
Force in the second tilt joint.
Definition: MAHead.hpp:84
Head state.
Definition: MAHead.hpp:55
MANum< int > Tilt1
First tilt joint degree (-80; 3)
Definition: MAHead.hpp:78
Robot state.