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(), &MoveInSteps::CreateInstance);
33 
34 static std::map<std::string, Vector3> StringToDirection =
35 {
36  {"forward", Vector3(0.0, 1.0, 0.0)},
37  {"left", Vector3(-1.0, 0.0, 0)},
38  {"right", Vector3(1.0, 0.0, 0)},
39  {"back", Vector3(0.0, -1.0, 0)}
40 };
41 
42 /*Vector3 MoveInSteps::elementwiseMultiply(Vector3 v, Vector3 w) {
43  return Vector3(v.x*w.x, v.y*w.y, v.z*w.z);
44 }*/
45 
47 {
48  auto dirIter = StringToDirection.find(in.getDirection());
49  if (dirIter != StringToDirection.end())
50  {
51  Vector3 dir = dirIter->second;
52  local.setRelativePose(Eigen::Vector3f(dir.toEigen() * in.getMillimeterPerStep()*in.getStepCount()));
53  }
54  else
55  {
56  ARMARX_WARNING << in.getDirection() << " is not a valid direction. Valid directions are: foreward, left, right, back";
57  }
58 }
59 
60 //void MoveInSteps::run()
61 //{
62 // // put your user code for the execution-phase here
63 // // runs in seperate thread, thus can do complex operations
64 // // should check constantly whether isRunningTaskStopped() returns true
65 //
66 //// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
67 // while (!isRunningTaskStopped()) // stop run function if returning true
68 // {
69 // // do your calculations
70 // }
71 //}
72 
73 //void MoveInSteps::onBreak()
74 //{
75 // // put your user code for the breaking point here
76 // // execution time should be short (<100ms)
77 //}
78 
80 {
81  // put your user code for the exit point here
82  // execution time should be short (<100ms)
83 }
84 
85 
86 // DO NOT EDIT NEXT FUNCTION
88 {
89  return XMLStateFactoryBasePtr(new MoveInSteps(stateData));
90 }
91 
armarx::PlatformGroup::MoveInSteps::onExit
void onExit() override
Definition: MoveInSteps.cpp:79
armarx::PlatformGroup::MoveInSteps::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: MoveInSteps.cpp:87
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::PlatformGroup::MoveInSteps::Registry
static SubClassRegistry Registry
Definition: MoveInSteps.h:47
IceInternal::Handle
Definition: forward_declarations.h:8
armarx::Vector3
The Vector3 class.
Definition: Pose.h:112
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::PlatformGroup::MoveInSteps::onEnter
void onEnter() override
Definition: MoveInSteps.cpp:46
armarx::Vector3::toEigen
virtual Eigen::Vector3f toEigen() const
Definition: Pose.cpp:134
memoryx::KBM::Vector3
Eigen::Vector3d Vector3
Definition: kbm.h:41
ARMARX_WARNING
#define ARMARX_WARNING
Definition: Logging.h:186
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28
armarx::PlatformGroup::MoveInSteps::MoveInSteps
MoveInSteps(const XMLStateConstructorParams &stateData)
Definition: MoveInSteps.h:34
MoveInSteps.h