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
28using namespace armarx;
29using namespace PlatformGroup;
30
31// DO NOT EDIT NEXT LINE
32MoveInSteps::SubClassRegistry MoveInSteps::Registry(MoveInSteps::GetName(),
34
35static 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
44void
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
81void
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
static SubClassRegistry Registry
Definition MoveInSteps.h:47
MoveInSteps(const XMLStateConstructorParams &stateData)
Definition MoveInSteps.h:33
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
The Vector3 class.
Definition Pose.h:113
virtual Eigen::Vector3f toEigen() const
Definition Pose.cpp:134
#define ARMARX_WARNING
The logging level for unexpected behaviour, but not a serious problem.
Definition Logging.h:193
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64