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 
31 using namespace armarx;
32 using namespace TrajectoryExecutionCode;
33 
34 // DO NOT EDIT NEXT LINE
35 PlayTrajectory::SubClassRegistry PlayTrajectory::Registry(PlayTrajectory::GetName(),
37 
38 void
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  }
62  TrajectoryPtr t = new Trajectory;
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 
89 void
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
99 {
100  return XMLStateFactoryBasePtr(new PlayTrajectory(stateData));
101 }
armarx::TrajectoryExecutionCode::PlayTrajectory::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: PlayTrajectory.cpp:98
armarx::XMLStateConstructorParams
Definition: XMLState.h:49
armarx::getRobotUnit
RobotUnit * getRobotUnit(RobotUnitModule::ControllerManagement *cmngr)
Definition: NJointController.cpp:35
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:64
IceInternal::Handle< Trajectory >
PlayTrajectory.h
armarx::RobotUnitModule::ControllerManagement::activateNJointController
void activateNJointController(const std::string &name, const Ice::Current &=Ice::emptyCurrent) override
Requests activation for the given NJointControllerBase.
Definition: RobotUnitModuleControllerManagement.cpp:338
armarx::TrajectoryExecutionCode::PlayTrajectory::onExit
void onExit() override
Definition: PlayTrajectory.cpp:90
armarx::TrajectoryExecutionCode::PlayTrajectory::PlayTrajectory
PlayTrajectory(const XMLStateConstructorParams &stateData)
Definition: PlayTrajectory.h:32
armarx::TrajectoryExecutionCode::PlayTrajectory::Registry
static SubClassRegistry Registry
Definition: PlayTrajectory.h:46
armarx::VariantType::Trajectory
const VariantTypeId Trajectory
Definition: Trajectory.h:44
armarx::TrajectoryExecutionCode::PlayTrajectory::onEnter
void onEnter() override
Definition: PlayTrajectory.cpp:39
Trajectory.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:181
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:27