Main Page · Modules · All Classes · Class Hierarchy
MABodyStandUpFromSitting.cpp
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 #include "MABodyStandUpFromSitting.hpp"
23 
24 #include "core/MARandomness.hpp"
25 #include "types/MAComplexIndicators.hpp"
26 #include "types/MARobotState.hpp"
27 #include "controllers/MAHeadController.hpp"
28 #include "controllers/MALegController.hpp"
29 #include "MABodyStateMaster.hpp"
30 #include "MABodyStroked.hpp"
31 #include "MASittingFreefall.hpp"
32 
33 MABodyStandUpFromSitting::MABodyStandUpFromSitting() : MABodyPoseTransition(MCGetClassName(this))
34 {
35  DesiredConnections[MCGetClassName<MABodyStateMaster>()] = -1.0;
36  DesiredConnections[MCGetClassName<MABodyStroked>()] = -1.0;
38 }
39 
40 
42 {
44 }
45 
46 
48 {
49  MA_RANDOM_POINT_1(SkitDurationScale, 100, 140);
50  std::string ScaleStr(':'+MCToStr((float)SkitDurationScale / 100));
51 
52  StartTransition(*MA::Head, "SKIT:sit_to_stand"+ScaleStr);
53  StartTransition(*MA::LegLF, "SKIT:sit_to_stand"+ScaleStr);
54  StartTransition(*MA::LegLH, "SKIT:sit_to_stand"+ScaleStr);
55  StartTransition(*MA::LegRF, "SKIT:sit_to_stand"+ScaleStr);
56  StartTransition(*MA::LegRH, "SKIT:sit_to_stand"+ScaleStr);
57 }
58 
59 
61 {
62  if (!MA::RobotState->ComplexIndicators->IsStandingPosture)
63  {
65  return;
66  }
67  // Note: The LegLF and LegRF are not switched off to preserve the posture stability at the cost of
68  // ~1.5 W additional power consumption, but the final consumption is still much lower compared to
69  // the normal conditions (14 W -> ~6.5 W).
70  // TODO: Enable power savings
71 // MA::LegLH->SetPower(MA::LegJoint1, false);
72 // MA::LegRH->SetPower(MA::LegJoint1, false);
73 }
#define MA_RANDOM_POINT_1(_variable_name, _min, _max)
Set a random point with one value.
MA::DesiredConnectionMap DesiredConnections
Desired connection map to other behaviors.
Definition: MABehavior.hpp:766
Base behavior for body pose transitions.
std::string MCToStr(const T value, bool hex_manipulator=false)
Convert an other type to string with std::stringstream.
Definition: MCDefs.hpp:360
void SetLifetimeExpirationTime(const unsigned int expiration_time)
Set the lifetime expiration time.
Definition: MABehavior.cpp:542
#define MABEHAVIOR_CREATE(_behavior, _master,...)
Create behaviors with custom constructor safely.
Definition: MABehavior.hpp:43
std::string MCGetClassName(T *instance=nullptr, const std::string &name_suffix="")
Get a class name.
Definition: MCDefs.hpp:627
virtual void FinishingActions() override
Perform actions when the behavior is being finished.
Freefall in sitting posture.
void StartTransition(MAController &controller, const std::string &transition_name)
Start a transition.
Definition: MABehavior.cpp:793
virtual void ActivatingActions() override
Perform actions when the behavior is being activated.
virtual MABehavior::StimulusLevelType GetCurrentStimulus() override
Get the current behavior stimulus.