Main Page · Modules · All Classes · Class Hierarchy
MARobotState.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/MACoreTypes.hpp"
25 #include "core/MASignal.hpp"
26 #include "MALeg.hpp"
27 
28 #include <MCDefs.hpp>
29 #include <MCThreadLocalData.hpp>
30 
31 #include <boost/scoped_ptr.hpp>
32 
33 #include <vector>
34 #include <map>
35 
36 #include <stdint.h>
37 
38 class MCBinaryData;
39 class MAAudio;
40 class MABodyMotion;
42 class MAEmotions;
43 class MAGoals;
44 class MAHead;
45 class MAHri;
46 template <typename T>
47 class MANum;
48 class MARobotState;
49 class MATorso;
50 
56 namespace MA
57 {
59 extern MCThreadLocalData<MARobotState> RobotState;
60 
62 typedef std::vector<int16_t> Int16List;
63 
65 typedef std::vector<MANum<int>*> MANumIntPtrList;
66 
68 typedef std::pair<int, MC::StringPtr> ValueNoteType;
70 typedef std::vector<ValueNoteType> ValueNoteList;
71 
73 typedef std::map<const MANum<int>*, ValueNoteList> MANumIntPtrValueNotesMap;
74 }
75 
80 {
81  MA_SLOT_CLASS
82 
91  MARobotState(bool static_instance = false, bool updates = false);
92 
100  MARobotState(const MARobotState& other);
101 
102  virtual ~MARobotState();
103 
104 private:
105 
114  void Init(bool static_instance, bool updates);
115 
116 public:
117 
127  MALeg& GetLeg(MA::Leg::LegTypes leg) const;
128 
136  std::string GetDecodedVariableMap() const;
137 
147  const MANum<int>* GetVariable(const std::string& variable_name) const;
148 
158  std::string GetDisplayName(const std::string& variable_name) const;
159 
167  MC::StringList GetVariableNames() const;
168 
178  MA::ValueNoteList GetValueNotes(const std::string& variable_name) const;
179 
189  std::string GetAsRichText(const MC::StringList& highlighted_variables = MC::StringList()) const;
190 
198  std::string GetAsNormalText() const;
199 
209  MARobotState& operator=(const MARobotState& other);
210 
220  MCBinaryData* Encode(bool encode_variable_map = true) const;
221 
233  static MARobotState* Decode(const MCBinaryData& data, const std::string& variable_map = "");
234 
235 protected:
236 
246  void BindVariable(const std::string& name, MANum<int>& variable, const std::string& display_name);
247 
253  void RemoveCustomVariables();
254 
255 private:
256 
264  int GetBinarySize() const;
265 
266 public:
268  boost::scoped_ptr<MATorso> Torso;
270  boost::scoped_ptr<MABodyMotion> BodyMotion;
272  boost::scoped_ptr<MALeg> LegLF;
274  boost::scoped_ptr<MALeg> LegLH;
276  boost::scoped_ptr<MALeg> LegRF;
278  boost::scoped_ptr<MALeg> LegRH;
280  boost::scoped_ptr<MAHead> Head;
282  boost::scoped_ptr<MAAudio> Audio;
284  boost::scoped_ptr<MAEmotions> Emotions;
286  boost::scoped_ptr<MAComplexIndicators> ComplexIndicators;
288  boost::scoped_ptr<MAGoals> Goals;
290  boost::scoped_ptr<MAHri> Hri;
291 private:
293  std::string** StrBasePtr;
295  MA::Int16List VariableNames;
297  MA::Int16List VariableDisplayNames;
299  MA::MANumIntPtrValueNotesMap VariableValueNotes;
301  std::string DecodedVariableMap;
303  MA::MANumIntPtrList Variables;
305  MA::MANumIntPtrList DecodedCustomVariables;
306 };
307 
Goals.
Definition: MAGoals.hpp:35
Torso states.
Definition: MATorso.hpp:97
Binary data class.
MA::MANumIntPtrValueNotesMap VariableValueNotes
Notes for variable values.
std::string DecodedVariableMap
Decoded variable map from the network decoder.
boost::scoped_ptr< MAComplexIndicators > ComplexIndicators
Complex indicators.
boost::scoped_ptr< MALeg > LegRH
LegRH.
MA::Int16List VariableNames
Variable names.
MA::Int16List VariableDisplayNames
Variable display names.
This class represents a number with bound check.
boost::scoped_ptr< MAGoals > Goals
Goals.
Audio input/output state.
Definition: MAAudio.hpp:63
boost::scoped_ptr< MABodyMotion > BodyMotion
Body motion.
boost::scoped_ptr< MALeg > LegLF
LegLF.
MA::MANumIntPtrList DecodedCustomVariables
Decoded custom variable pointers.
boost::scoped_ptr< MAEmotions > Emotions
Emotions.
std::string ** StrBasePtr
Variable names.
boost::scoped_ptr< MALeg > LegRF
LegRF.
State indicators.
Definition: MAEmotions.hpp:62
MA::MANumIntPtrList Variables
Variable pointers.
boost::scoped_ptr< MAAudio > Audio
Audio input/output.
Body motion states.
A wrapper class to cover boost::thread_specific_ptr/folly::ThreadLocal API on certain targets...
boost::scoped_ptr< MAHri > Hri
Human-robot interaction data.
A leg class.
Definition: MALeg.hpp:71
boost::scoped_ptr< MATorso > Torso
Torso.
Human-robot interaction data.
Definition: MAHri.hpp:34
Head state.
Definition: MAHead.hpp:55
boost::scoped_ptr< MALeg > LegLH
LegLH.
Robot state.
Complex state indicators.
boost::scoped_ptr< MAHead > Head
Head.