Main Page · Modules · All Classes · Class Hierarchy
MAHeadController.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 <boost/shared_ptr.hpp>
25 
26 #include <MCThreadLocalData.hpp>
27 
28 #include "core/MAValueGenerators.hpp"
29 #include "types/MABodyTypes.hpp"
30 #include "MAController.hpp"
31 
32 class MACameraDevice;
33 class MADevice;
34 class MAHeadController;
35 class MAMicrophoneDevice;
36 class MARobotState;
37 
43 namespace MA
44 {
47 }
48 
51 {
53 
54  void AddGeneratorToNeckTilt1(MAGeneratorBase& generator);
55  void AddGeneratorToNeckTilt2(MAGeneratorBase& generator);
56  void AddGeneratorToNeckPan(MAGeneratorBase& generator);
57  void AddDelayToNeckJoints(int duration = 300);
58  void Normalize();
59 
60  MAGeneratorContainer* NeckTilt1;
61  MAGeneratorContainer* NeckTilt2;
62  MAGeneratorContainer* NeckPan;
63 };
64 
69 {
70 public:
74  virtual ~MAHeadController();
75 
76 private:
77  virtual void UpdateRobotState(MARobotState& state) override;
78 
79 public:
80  virtual MA::DeviceList GetMotors() const override;
81  MADevice* GetMotor(const MA::HeadJointsType joint) const;
82  MA::HeadJointsType GetMotorType(const MADevice& motor) const;
83  void SetPower(bool new_state);
84  bool IsPowerOn() const;
85  bool IsMovingNeck() const;
86  bool IsTurnedDown() const;
87  bool IsTurnedAhead() const;
88  bool IsUp() const;
89  MA_DECLARE_TRANSITION(TurnDownAndAhead, IsTurnedDownAndAhead)
90  MA_DECLARE_TRANSITION(TurnUp, IsTurnedUp)
91  MA_DECLARE_TRANSITION(ToNormalAhead, IsNormalAhead)
92  MA_DECLARE_TRANSITION_ACTION(GoRubbing)
93  MA_DECLARE_TRANSITION_ACTION(RubToLeft)
94  MA_DECLARE_TRANSITION_ACTION(RubToRight)
95  MA_DECLARE_TRANSITION_ACTION(FinishRubbing)
96  MA_DECLARE_TRANSITION_ACTION(DoCircle)
97  MA_DECLARE_TRANSITION_ACTION(HappyMoveToUp)
98  std::string DoHappyMovement();
99  MA_DECLARE_TRANSITION_ACTION(LookAroundLying)
100  MA_DECLARE_TRANSITION_ACTION(LookAroundSitting)
101  MA_DECLARE_TRANSITION_ACTION(TurnLeftLying)
102  MA_DECLARE_TRANSITION_ACTION(TurnRightLying)
103  MA_DECLARE_TRANSITION_ACTION(TurnLeftSitting)
104  MA_DECLARE_TRANSITION_ACTION(TurnRightSitting)
105  void Stop();
106  void PrintFeatures();
107  bool IsPowerOn(MA::HeadJointsType joint) const;
108  void SetPower(MA::HeadJointsType joint, bool new_state);
109 
110 protected:
111  void RegisterDeviceUpdates();
112  void NotifyDeviceUpdate(MADevice& device);
113  void Stop(MA::HeadJointsType joint);
114  void CreateGenerators(MAHeadTransitionGenerators& generators, const MABodyPartFeature& feature,
116  virtual MA::DeviceGeneratorsMap GetSkitTransitionGenerators(MA::SkitBaseSPtr skit) override;
117  MA::DeviceGeneratorsMap ApplyGenerators(MAHeadTransitionGenerators& generators, bool clear = false);
118 
120  boost::shared_ptr<MADevice> NeckTilt1;
122  boost::shared_ptr<MADevice> NeckTilt2;
124  boost::shared_ptr<MADevice> NeckPan;
126  boost::shared_ptr<MADevice> ChinButton;
128  boost::shared_ptr<MADevice> CrownButton;
130  boost::shared_ptr<MACameraDevice> Camera;
132  boost::shared_ptr<MAMicrophoneDevice> Microphone;
133  /*
134  * Left-right direction of the head
135  * -100 - left 100 - right
136  */
137  MALeftRightTurned LeftRightTurned;
138  /*
139  * Fore-back and up-down direction of the head
140  * -100 - back 100 - fore
141  * -100 - down 100 - up
142  */
143  MAHeadPosition HeadPosition;
148 };
149 
boost::shared_ptr< MADevice > NeckTilt1
Neck tilt1.
Helper class to build head transition generators.
boost::shared_ptr< MAMicrophoneDevice > Microphone
Microphone.
boost::shared_ptr< MADevice > NeckTilt2
Neck tilt2.
Base class for the controllers.
float RubbingCenterForeBack
Store the center (fore-back) position of the rubbing.
Device class.
Definition: MADevice.hpp:57
A base class for the limb features.
Definition: MABodyTypes.hpp:56
The left-right turning feature of the head.
boost::shared_ptr< MADevice > NeckPan
Neck pan.
Generator container class.
boost::shared_ptr< MACameraDevice > Camera
Camera.
boost::shared_ptr< MADevice > CrownButton
Crown sensor.
Base class for generators.
Head controller class.
float RubbingCenterLeftRight
Store the center (left-right) position of the rubbing.
A wrapper class to cover boost::thread_specific_ptr/folly::ThreadLocal API on certain targets...
Robot state.
boost::shared_ptr< MADevice > ChinButton
Chin sensor.
The fore-back, up-down position of the head.