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>
26 
28 
29 //#include <ArmarXCore/core/time/TimeUtil.h>
30 //#include <ArmarXCore/observers/variant/DatafieldRef.h>
31 
32 using namespace armarx;
33 using namespace TrajectoryExecutionCode;
34 
35 // DO NOT EDIT NEXT LINE
36 PlayTrajectory::SubClassRegistry PlayTrajectory::Registry(PlayTrajectory::GetName(), &PlayTrajectory::CreateInstance);
37 
38 
39 
41 {
42  // put your user code for the enter-point here
43  // execution time should be short (<100ms)
44  NJointTrajectoryControllerConfigPtr cfg(new NJointTrajectoryControllerConfig());
45  cfg->jointNames.push_back("Hip Yaw");
46  cfg->maxAcceleration = 0.05;
47  cfg->maxVelocity = 0.3;
48  NJointTrajectoryControllerInterfacePrx prx = NJointTrajectoryControllerInterfacePrx::checkedCast(getRobotUnit()->getNJointController("ActorNJointTrajectoryController"));
49  if (!prx)
50  {
51  prx = NJointTrajectoryControllerInterfacePrx::checkedCast(getRobotUnit()->createNJointController("NJointTrajectoryController", "ActorNJointTrajectoryController", cfg));
52 
53  }
54  else
55  {
56  ARMARX_INFO << "deactivating controller";
57  prx->deactivateController();
58  ARMARX_INFO << "DONE deactivating controller";
59  }
60  TrajectoryPtr t = new Trajectory;
61 
62  Ice::DoubleSeq sr = {0, 1, 1.6, 1, 0};
63  t->addDimension(sr, {}, "Hip Yaw");
64  prx->setTrajectory(t);
65  getRobotUnit()->activateNJointController("ActorNJointTrajectoryController");
66 }
67 
68 //void PlayTrajectory::run()
69 //{
70 // // put your user code for the execution-phase here
71 // // runs in seperate thread, thus can do complex operations
72 // // should check constantly whether isRunningTaskStopped() returns true
73 //
74 //// uncomment this if you need a continous run function. Make sure to use sleep or use blocking wait to reduce cpu load.
75 // while (!isRunningTaskStopped()) // stop run function if returning true
76 // {
77 // // do your calculations
78 // }
79 //}
80 
81 //void PlayTrajectory::onBreak()
82 //{
83 // // put your user code for the breaking point here
84 // // execution time should be short (<100ms)
85 //}
86 
88 {
89  // put your user code for the exit point here
90  // execution time should be short (<100ms)
91 }
92 
93 
94 // DO NOT EDIT NEXT FUNCTION
96 {
97  return XMLStateFactoryBasePtr(new PlayTrajectory(stateData));
98 }
99 
armarx::TrajectoryExecutionCode::PlayTrajectory::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: PlayTrajectory.cpp:95
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::getRobotUnit
RobotUnit * getRobotUnit(RobotUnitModule::ControllerManagement *cmngr)
Definition: NJointController.cpp:35
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:87
armarx::TrajectoryExecutionCode::PlayTrajectory::PlayTrajectory
PlayTrajectory(const XMLStateConstructorParams &stateData)
Definition: PlayTrajectory.h:33
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:40
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
Trajectory.h
ARMARX_INFO
#define ARMARX_INFO
Definition: Logging.h:174
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28