PlayTrajectory.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 RobotAPI::TrajectoryExecutionCode
17 * @author Mirko Waechter ( mirko dot waechter at kit dot edu )
18 * @date 2017
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#include "PlayTrajectory.h"
24
25#include <RobotAPI/interface/units/RobotUnit/NJointTrajectoryController.h>
27
28//#include <ArmarXCore/core/time/TimeUtil.h>
29//#include <ArmarXCore/observers/variant/DatafieldRef.h>
30
31using namespace armarx;
32using namespace TrajectoryExecutionCode;
33
34// DO NOT EDIT NEXT LINE
35PlayTrajectory::SubClassRegistry PlayTrajectory::Registry(PlayTrajectory::GetName(),
37
38void
40{
41 // put your user code for the enter-point here
42 // execution time should be short (<100ms)
43 NJointTrajectoryControllerConfigPtr cfg(new NJointTrajectoryControllerConfig());
44 cfg->jointNames.push_back("Hip Yaw");
45 cfg->maxAcceleration = 0.05;
46 cfg->maxVelocity = 0.3;
47 NJointTrajectoryControllerInterfacePrx prx =
48 NJointTrajectoryControllerInterfacePrx::checkedCast(
49 getRobotUnit()->getNJointController("ActorNJointTrajectoryController"));
50 if (!prx)
51 {
52 prx = NJointTrajectoryControllerInterfacePrx::checkedCast(
53 getRobotUnit()->createNJointController(
54 "NJointTrajectoryController", "ActorNJointTrajectoryController", cfg));
55 }
56 else
57 {
58 ARMARX_INFO << "deactivating controller";
59 prx->deactivateController();
60 ARMARX_INFO << "DONE deactivating controller";
61 }
63
64 Ice::DoubleSeq sr = {0, 1, 1.6, 1, 0};
65 t->addDimension(sr, {}, "Hip Yaw");
66 prx->setTrajectory(t);
67 getRobotUnit()->activateNJointController("ActorNJointTrajectoryController");
68}
69
70//void PlayTrajectory::run()
71//{
72// // put your user code for the execution-phase here
73// // runs in seperate thread, thus can do complex operations
74// // should check constantly whether isRunningTaskStopped() returns true
75//
76//// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
77// while (!isRunningTaskStopped()) // stop run function if returning true
78// {
79// // do your calculations
80// }
81//}
82
83//void PlayTrajectory::onBreak()
84//{
85// // put your user code for the breaking point here
86// // execution time should be short (<100ms)
87//}
88
89void
91{
92 // put your user code for the exit point here
93 // execution time should be short (<100ms)
94}
95
96// DO NOT EDIT NEXT FUNCTION
void activateNJointController(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
Requests activation for the given NJointControllerBase.
PlayTrajectory(const XMLStateConstructorParams &stateData)
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
The Trajectory class represents n-dimensional sampled trajectories.
Definition Trajectory.h:77
#define ARMARX_INFO
The normal logging level.
Definition Logging.h:181
This file offers overloads of toIce() and fromIce() functions for STL container types.
RobotUnit * getRobotUnit(RobotUnitModule::ControllerManagement *cmngr)
IceInternal::Handle< Trajectory > TrajectoryPtr
Definition Trajectory.h:52
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64