Main Page · Modules · All Classes · Class Hierarchy
MABodyMotion.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 <MCTimer.hpp>
28 
38 {
40  MAAccelData();
41 
46 };
47 
48 namespace MA
49 {
51 typedef enum
52 {
53  UnknownBodyState = -1,
54  NormalBodyState = 1,
55  PickupMode = 2,
56  FallingOver = 3,
57  Poked = 4,
58 } BodyStateType;
59 
61 typedef enum
62 {
63  UnknownFloor = -500,
64  WoodFlooring = 0,
65  Field = 500,
66  Carpet = 1000,
67  FoamMat = 1500,
68  Vinyl = 2000,
69  Tiles = 2500,
70  CarpetedFloor = 3000,
71  UserDefinedFloor = 10000,
72 } FloorSurfacesType;
73 
75 typedef enum
76 {
77  HardFlooring = 0,
78  SoftFlooring = 10,
79  VerySoftFlooring = 20,
80 } FloorSurfaceSoftnessType;
81 }
82 
92 std::string MAFloorSurfacesTypeStr(const MA::FloorSurfacesType surface);
93 
103 std::string MAFloorSurfaceSoftnessTypeStr(const MA::FloorSurfaceSoftnessType surface_softness);
104 
114 MA::FloorSurfaceSoftnessType MAMapFloorSurfaceToSoftness(const MA::FloorSurfacesType surface);
115 
120 {
122  MAFloorSurface();
123 
124  /*
125  * Floor surface
126  *
127  * -1 - Unknown
128  * 0 - Wood flooring
129  * 500 - Field
130  * 1000 - Carpet
131  * 1500 - Foam mat
132  * 2000 - Vinyl
133  * 2500 - Tiles
134  * 3000 - Carpeted floor
135  * 3500 - User defined floor
136  *
137  */
138  MANum<int> Surface;
139  /*
140  * Current floor surface
141  *
142  * -1 - Unknown
143  * 0 - Wood flooring
144  * 500 - Field
145  * 1000 - Carpet
146  * 1500 - Foam mat
147  * 2000 - Vinyl
148  * 2500 - Tiles
149  * 3000 - Carpeted floor
150  * 3500 - User defined floor
151  *
152  */
153  MANum<int> CurrentSurface;
154  /*
155  * Owner feedback about the real surface
156  *
157  * -1 - Unknown
158  * 0 - Wood flooring
159  * 500 - Field
160  * 1000 - Carpet
161  * 1500 - Foam mat
162  * 2000 - Vinyl
163  * 2500 - Tiles
164  * 3000 - Carpeted floor
165  * 3500 - User defined floor
166  *
167  */
168  MANum<int> OwnerFeedback;
169 };
170 
175 {
177  MABodyMotion();
178 
186  bool IsBodyRollInWalkRange() const;
187 
193  void StartMotionControlTimer();
194 
200  void StopMotionControlTimer();
201 
202 private:
203  virtual void UpdateRobotState(MARobotState& state) override;
204 
205  void GenerateBodyPitchAndRoll();
206  void GenerateLyingOnBack(MARobotState& state);
207  void GenerateLyingOnBackLeftSide(MARobotState& state);
208  void GenerateLyingOnBackRightSide(MARobotState& state);
209  void GenerateBodyOnLeftSide(MARobotState& state);
210  void GenerateBodyOnRightSide(MARobotState& state);
211  void GenerateLying(MARobotState& state);
212  void GenerateLyingOnLeftSide(MARobotState& state);
213  void GenerateLyingOnRightSide(MARobotState& state);
214  void GenerateSitting(MARobotState& state);
215  void GenerateFlying(MARobotState& state);
216  void GeneratePoked(MARobotState& state);
217 
218 public:
219  /*
220  * The robot is on the charging station
221  * 0 - Not on station 1 - The dog is on the station
222  */
223  MANum<int> OnStation;
234  /*
235  * The orientation of the body of the robot
236  * 0 - Normal orientation 100 - The body is upside down
237  */
238  MANum<int> UpsideDown;
239  /*
240  * The body of the robot in lateral position
241  * 0 - On the left side 50 - Upside down 100 - On the right side
242  */
243  MANum<int> LateralPosition;
244  /*
245  * How much the orientation is head stand
246  * 0 - Head stand 100 - Back stand.
247  */
248  MANum<int> HeadStand;
249  /*
250  * The robot is lying on its back
251  * 0 - Not on the back 100 - On the back
252  */
253  MANum<int> LyingOnBack;
254  /*
255  * The robot is lying on the back/left side
256  * 0 - Not in position 100 - Lying on the back/left side
257  */
258  MANum<int> LyingOnBackLeftSide;
259  /*
260  * The robot is lying on the back/right side
261  * 0 - Not in position 100 - Lying on the back/right side
262  */
263  MANum<int> LyingOnBackRightSide;
264  /*
265  * The robot body is on the left side
266  * 0 - Not in position 100 - Lying on the left side
267  */
268  MANum<int> BodyOnLeftSide;
269  /*
270  * The robot body is on the right side
271  * 0 - Not in position 100 - Lying on the right side
272  */
273  MANum<int> BodyOnRightSide;
274  /*
275  * The robot is in lying position
276  * 0 - Not lying 100 - Lying
277  */
278  MANum<int> Lying;
279  /*
280  * The robot is lying on the left side
281  * 0 - Not in position 100 - Lying on the left side
282  */
283  MANum<int> LyingOnLeftSide;
284  /*
285  * The robot is lying on the right side
286  * 0 - Not in position 100 - Lying on the right side
287  */
288  MANum<int> LyingOnRightSide;
289  /*
290  * The robot is in sitting position
291  * 0 - Not sitting 100 - Sitting
292  */
293  MANum<int> Sitting;
294  /*
295  * The robot is held and carried in the air ("flying")
296  * 0 - Not flying 100 - Flying
297  */
298  MANum<int> Flying;
299  /*
300  * The robot body is poked
301  * 0 - Not poked 100 - Poked
302  */
303  MANum<int> Poked;
304  /*
305  * Whenever the robot body performs a Skitter playback
306  * 0 - Normal 1 - Skitter playback in progress
307  */
308  MANum<int> SkitterPlayback;
319 private:
321  MAIntervalNum<int> BackStrokedFactor;
323  MAIntervalNum<int> LyingOnBackFactor;
325  MAIntervalNum<int> LyingOnBackLeftSideFactor;
327  MAIntervalNum<int> LyingOnBackRightSideFactor;
329  MAIntervalNum<int> BodyOnLeftSideFactor;
331  MAIntervalNum<int> BodyOnRightSideFactor;
333  MAIntervalNum<int> LyingFactor;
335  MAIntervalNum<int> LyingOnLeftSideFactor;
337  MAIntervalNum<int> LyingOnRightSideFactor;
339  MAIntervalNum<int> SittingFactor;
341  MAIntervalNum<int> FlyingFactor;
343  MAIntervalNum<int> PokedFactor;
346 };
347 
MAIntervalNum< int > LyingOnBackFactor
Indicator variable when the robot body is lying upside down.
MANum< int > Degree
Degree (-90°..90°)
MAIntervalNum< int > LyingOnBackRightSideFactor
Indicator variable when the robot body is lying upside down/right side.
MAIntervalNum< int > LyingOnBackLeftSideFactor
Indicator variable when the robot body is lying upside down/left side.
Accelerometer data.
MANum< int > MotionControlAge
Elapsed time since the last motion control command (in seconds)
MANum< int > SkitPlayback
Any skit is played back.
MANum< int > BodyRoll
Body roll.
MAIntervalNum< int > SittingFactor
Indicator variable for sitting position.
Floor surface struct.
MANum< int > InMotion
Any body part is in motion.
MAIntervalNum< int > LyingFactor
Indicator variable when the robot body is lying.
MANum< int > Raw
Raw data (-19613300..19613300)
MCTimer MotionControlTimer
Motion control command timer.
MAIntervalNum< int > LyingOnRightSideFactor
Indicator variable when the robot body is lying on its right side.
MAIntervalNum< int > FlyingFactor
Indicator variable to detect the flying (pick-up) mode.
MAIntervalNum< int > BodyOnRightSideFactor
Indicator variable when the robot body is on its right side.
MANum< int > BodyPitch
Body pitch.
MAAccelData AccelZ
Accelerometer (Z dimension, up-down)
std::string MAFloorSurfacesTypeStr(const MA::FloorSurfacesType surface)
Get floor surface string.
MAIntervalNum< int > BodyOnLeftSideFactor
Indicator variable when the robot body is on its left side.
Robot state updater base class.
Simple timer class with microsecond precision.
Definition: MCTimer.hpp:59
MAIntervalNum< int > LyingOnLeftSideFactor
Indicator variable when the robot body is lying on its left side.
Body motion states.
MA::FloorSurfaceSoftnessType MAMapFloorSurfaceToSoftness(const MA::FloorSurfacesType surface)
Map a floor surface to softness.
MAIntervalNum< int > PokedFactor
Indicator variable to detect the poked state.
std::string MAFloorSurfaceSoftnessTypeStr(const MA::FloorSurfaceSoftnessType surface_softness)
Get floor surface softness string.
MAAccelData AccelY
Accelerometer (Y dimension, left-right)
MAAccelData()
Struct constructor.
MANum< int > BodyState
Body state.
Robot state.
MAFloorSurface Floor
Floor surface.
MAIntervalNum< int > BackStrokedFactor
Indicator variable when the robot back is stroked.
MAAccelData AccelX
Accelerometer (X dimension, front-back)