Standing.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2018-2019, CNRS-UM LIRMM
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25  * POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 
30 #include <mc_control/fsm/Controller.h>
31 #include <mc_control/fsm/State.h>
32 
34 #include <lipm_walking/State.h>
35 
36 namespace lipm_walking
37 {
38 
39 namespace states
40 {
41 
53 struct Standing : State
54 {
58  void start() override;
59 
63  void teardown() override;
64 
68  void checkPlanUpdates();
69 
73  bool checkTransitions() override;
74 
78  void runState() override;
79 
83  void distributeFootCoPs();
84 
90  void updateTarget(double leftFootRatio);
91 
99  void makeFootContact(std::shared_ptr<mc_tasks::force::CoPTask> footTask, const Contact & contact);
100 
104  void makeLeftFootContact();
105 
109  void makeRightFootContact();
110 
117  bool releaseFootContact(std::shared_ptr<mc_tasks::force::CoPTask> footTask);
118 
122  void releaseLeftFootContact();
123 
128 
132  void startWalking();
133 
134 protected:
140  void updatePlan(const std::string & name);
141 
142 private:
143  Contact leftFootContact_;
144  Contact rightFootContact_;
145  Eigen::Vector3d copTarget_;
146  bool isMakingFootContact_;
147  bool planChanged_;
148  bool startWalking_;
149  double freeFootGain_;
150  double leftFootRatio_;
151  double releaseHeight_;
152  unsigned lastInterpolatorIter_;
153 };
154 
155 } // namespace states
156 
157 } // namespace lipm_walking
void distributeFootCoPs()
Distribute spatial ZMP into foot CoPs in double support.
Enable stabilizer and keep CoM at a reference position.
Definition: Standing.h:53
void checkPlanUpdates()
Check for footstep plan updates.
Definition: Standing.cpp:205
bool releaseFootContact(std::shared_ptr< mc_tasks::force::CoPTask > footTask)
Release foot contact.
Definition: Standing.cpp:266
void startWalking()
Enable startWalking_ boolean and update GUI.
Definition: Standing.cpp:329
Convenience wrapper for FSM states.
Definition: State.h:38
void makeLeftFootContact()
Make left foot contact.
Definition: Standing.cpp:256
void releaseRightFootContact()
Release right foot contact.
Definition: Standing.cpp:296
void updatePlan(const std::string &name)
Change footstep plan.
Definition: Standing.cpp:342
void updateTarget(double leftFootRatio)
Update target CoM and CoP.
Definition: Standing.cpp:226
Main controller namespace.
Definition: build.dox:1
void runState() override
Main state function, called if no transition at this cycle.
Definition: Standing.cpp:156
Contacts wrap foot frames with extra info from the footstep plan.
Definition: Contact.h:58
void makeRightFootContact()
Make right foot contact.
Definition: Standing.cpp:261
void makeFootContact(std::shared_ptr< mc_tasks::force::CoPTask > footTask, const Contact &contact)
Make foot contact.
Definition: Standing.cpp:241
void start() override
Start state.
Definition: Standing.cpp:41
bool checkTransitions() override
Check transitions at beginning of control cycle.
Definition: Standing.cpp:304
void releaseLeftFootContact()
Release left foot contact.
Definition: Standing.cpp:288
void teardown() override
Teardown state.
Definition: Standing.cpp:131