MoveInSteps.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * ArmarX is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License version 2 as
6  * published by the Free Software Foundation.
7  *
8  * ArmarX is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * @package RobotSkillTemplates::PlatformGroup
17  * @author Pascal Weiner ( pascal dot weiner at kit dot edu )
18  * @date 2018
19  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20  * GNU General Public License
21  */
22 
23 #include "MoveInSteps.h"
24 
25 //#include <ArmarXCore/core/time/TimeUtil.h>
26 //#include <ArmarXCore/observers/variant/DatafieldRef.h>
27 
28 using namespace armarx;
29 using namespace PlatformGroup;
30 
31 // DO NOT EDIT NEXT LINE
32 MoveInSteps::SubClassRegistry MoveInSteps::Registry(MoveInSteps::GetName(),
34 
35 static std::map<std::string, Vector3> StringToDirection = {{"forward", Vector3(0.0, 1.0, 0.0)},
36  {"left", Vector3(-1.0, 0.0, 0)},
37  {"right", Vector3(1.0, 0.0, 0)},
38  {"back", Vector3(0.0, -1.0, 0)}};
39 
40 /*Vector3 MoveInSteps::elementwiseMultiply(Vector3 v, Vector3 w) {
41  return Vector3(v.x*w.x, v.y*w.y, v.z*w.z);
42 }*/
43 
44 void
46 {
47  auto dirIter = StringToDirection.find(in.getDirection());
48  if (dirIter != StringToDirection.end())
49  {
50  Vector3 dir = dirIter->second;
51  local.setRelativePose(
52  Eigen::Vector3f(dir.toEigen() * in.getMillimeterPerStep() * in.getStepCount()));
53  }
54  else
55  {
57  << in.getDirection()
58  << " is not a valid direction. Valid directions are: foreward, left, right, back";
59  }
60 }
61 
62 //void MoveInSteps::run()
63 //{
64 // // put your user code for the execution-phase here
65 // // runs in seperate thread, thus can do complex operations
66 // // should check constantly whether isRunningTaskStopped() returns true
67 //
68 //// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
69 // while (!isRunningTaskStopped()) // stop run function if returning true
70 // {
71 // // do your calculations
72 // }
73 //}
74 
75 //void MoveInSteps::onBreak()
76 //{
77 // // put your user code for the breaking point here
78 // // execution time should be short (<100ms)
79 //}
80 
81 void
83 {
84  // put your user code for the exit point here
85  // execution time should be short (<100ms)
86 }
87 
88 // DO NOT EDIT NEXT FUNCTION
91 {
92  return XMLStateFactoryBasePtr(new MoveInSteps(stateData));
93 }
armarx::PlatformGroup::MoveInSteps::onExit
void onExit() override
Definition: MoveInSteps.cpp:82
armarx::PlatformGroup::MoveInSteps::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: MoveInSteps.cpp:90
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::PlatformGroup::MoveInSteps::Registry
static SubClassRegistry Registry
Definition: MoveInSteps.h:47
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::Vector3
The Vector3 class.
Definition: Pose.h:112
armarx::PlatformGroup::MoveInSteps::onEnter
void onEnter() override
Definition: MoveInSteps.cpp:45
armarx::Vector3::toEigen
virtual Eigen::Vector3f toEigen() const
Definition: Pose.cpp:134
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:43
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:193
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27
armarx::PlatformGroup::MoveInSteps::MoveInSteps
MoveInSteps(const XMLStateConstructorParams &stateData)
Definition: MoveInSteps.h:33
MoveInSteps.h