KeypointsAdmittanceController.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 TaskSpaceActiveImpedanceControl::ArmarXObjects::NJointTaskSpaceImpedanceController
17 * @author zhou ( you dot zhou 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
24
26{
27 NJointControllerRegistration<NJointKeypointsAdmittanceMPController>
29 "NJointKeypointsAdmittanceMPController");
30
32 const RobotUnitPtr& robotUnit,
33 const NJointControllerConfigPtr& config,
34 const VirtualRobot::RobotPtr& robot) :
35 NJointKeypointsAdmittanceController{robotUnit, config, robot}, mp::MPPool{}
36 {
38 }
39
40 std::string
42 {
43 return "NJointKeypointsAdmittanceMPController";
44 }
45
46 void
48 const Ice::Current&)
49 {
51 reconfigureMPs(filename);
52 }
53
54 void
56 {
57 /// parse arguments and run mp
58 for (auto mp : mps)
59 {
60 if (mp.second.mp->getClassName() == "KeypointsMP")
61 {
63 std::dynamic_pointer_cast<mp::KeypointsMPInput>(mp.second.input);
64 in->keypointPosition = controlStatusBuffer.getReadBuffer().filteredKeypointPosition;
65 in->keypointVelocity = controlStatusBuffer.getReadBuffer().currentKeypointVelocity;
66 in->deltaT = controlStatusBuffer.getReadBuffer().deltaT;
67 // ARMARX_INFO << "additional Task: " << VAROUT(in->keypointPosition) << VAROUT(in->keypointVelocity) << VAROUT(in->keypointVelocity.size());
68 }
69 }
70 runMPs(true);
71 for (auto mp : mps)
72 {
73 if (mp.second.mp->getClassName() == "KeypointsMP" and !mp.second.mp->isFinished())
74 {
76 std::dynamic_pointer_cast<mp::KeypointsMPOutput>(mp.second.output);
77 getWriterControlStruct().desiredKeypointPosition = out->keypointPosition;
78 getWriterControlStruct().desiredKeypointVelocity = out->keypointVelocity;
80 // ARMARX_INFO << "additional Task: " << VAROUT(out->keypointPosition) << VAROUT(out->keypointVelocity) << VAROUT(out->keypointVelocity.size());
81 }
82 }
83 }
84
85 void
87 {
88 ARMARX_IMPORTANT << "rt pre activate: reinitialize the mp input output, as well as the rt "
89 "related buffer values";
91 for (auto mp : mps)
92 {
93 if (mp.second.mp->getClassName() == "KeypointsMP")
94 {
95 ARMARX_IMPORTANT << "initialize input output buffers between KeypointsMP and "
96 "keypoint controllers";
97
98 auto in = std::dynamic_pointer_cast<mp::KeypointsMPInput>(mp.second.input);
99 in->keypointPosition = controller.s.filteredKeypointPosition;
100 in->keypointVelocity = controller.s.currentKeypointVelocity;
101
102 auto out = std::dynamic_pointer_cast<mp::KeypointsMPOutput>(mp.second.output);
103 out->keypointPosition = controller.s.filteredKeypointPosition;
104 out->keypointVelocity = controller.s.currentKeypointVelocity;
105 // ARMARX_INFO << VAROUT(in->keypointPosition) << VAROUT(in->keypointVelocity) << VAROUT(out->keypointPosition) << VAROUT(out->keypointVelocity) << VAROUT(controller.s.numPoints);
106 }
107 }
108 }
109} // namespace armarx::control::njoint_mp_controller::task_space
void reconfigureMPs(const MPListConfig &mpListConfig)
Definition MPPool.cpp:97
void createMPs(const MPListConfig &mpListConfig)
Definition MPPool.cpp:23
std::map< std::string, MPInputOutput > mps
Definition MPPool.h:146
TripleBuffer< law::KeypointsAdmittanceController::Status > controlStatusBuffer
set buffers
NJointKeypointsAdmittanceController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void reconfigureController(const std::string &filename, const Ice::Current &iceCurrent=Ice::emptyCurrent) override
set control target
void rtPreActivateController() override
This function is called before the controller is activated.
NJointKeypointsAdmittanceMPController(const RobotUnitPtr &robotUnit, const NJointControllerConfigPtr &config, const VirtualRobot::RobotPtr &)
void rtPreActivateController() override
This function is called before the controller is activated.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
std::shared_ptr< class Robot > RobotPtr
Definition Bus.h:19
This file is part of ArmarX.
std::shared_ptr< KeypointsMPInput > KeypointsMPInputPtr
Definition KeypointsMP.h:45
std::shared_ptr< KeypointsMPOutput > KeypointsMPOutputPtr
Definition KeypointsMP.h:46
NJointControllerRegistration< NJointKeypointsAdmittanceMPController > registrationControllerNJointKeypointsAdmittanceMPController("NJointKeypointsAdmittanceMPController")
IceUtil::Handle< class RobotUnit > RobotUnitPtr
Definition FTSensor.h:34