VisualServo.cpp
Go to the documentation of this file.
1 /*
2  * This file is part of ArmarX.
3  *
4  * Copyright (C) 2014-2016, High Performance Humanoid Technologies (H2T), Karlsruhe Institute of Technology (KIT), all rights reserved.
5  *
6  * ArmarX is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License version 2 as
8  * published by the Free Software Foundation.
9  *
10  * ArmarX is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  *
18  * @package RobotSkillTemplates::FindAndGraspObjectGroup
19  * @author Valerij Wittenbeck ( valerij dot wittenbeck at student dot kit dot edu )
20  * @date 2014
21  * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
22  * GNU General Public License
23  */
24 
25 #include "VisualServo.h"
26 
27 using namespace armarx;
28 using namespace FindAndGraspObjectGroup;
29 
30 // DO NOT EDIT NEXT LINE
32 
33 
34 
36  XMLStateTemplate < VisualServo > (stateData)
37 {
38 }
39 
41 {
42  ARMARX_VERBOSE << "Entering VisualServo::onEnter()";
43 
44  // timeout condition (Failure)
45  float visualServoTimeoutMS = getInput<float>("timeoutTotalMsec");
46  condServoTimeout = setTimeoutEvent(visualServoTimeoutMS, createEvent<Failure>());
47 
48  float minRecognitionLikelihood = getInput<float>("minRecognitionLikelihood");
49 
50  //OLD:
51  /*
52  // object lost condition (Failure) //TODO (maybe): move this to the VSExample (where the condObjectUpdate also is)
53  ChannelRefPtr objectChannel = getInput<ChannelRef>("objectChannel");
54  Literal objectLost(*objectChannel->getDataFieldIdentifier("existenceCertainty"), "smaller", Literal::createParameterList(minRecognitionLikelihood));
55  condObjectLost = installCondition(objectLost, createEvent<Failure>());
56  */
57 
58  // marker lost condition (Failure)
59  ChannelRefPtr markerChannel = getInput<ChannelRef>("markerChannel");
60  Literal markerLost(*markerChannel->getDataFieldIdentifier("existenceCertainty"), "smaller", Literal::createParameterList(minRecognitionLikelihood));
61  condMarkerLost = installCondition(markerLost, createEvent<Failure>());
62 
63  ARMARX_IMPORTANT << "Done VisualServo::onEnter()";
64 }
65 
67 {
68  // VisualServoContext* visualServoContext = getContext<VisualServoContext>();
69 
70  // std::string robotNodeSetName = getInput<std::string>("kinematicChain");
71  // VirtualRobot::RobotPtr localRobot = RemoteRobot::createLocalClone(visualServoContext->robotStateComponent);
72  // VirtualRobot::RobotNodeSetPtr robotNodeSet = visualServoContext->remoteRobot->getRobotNodeSet(robotNodeSetName);
73  // VirtualRobot::RobotNodeSetPtr robotNodeSet = localRobot->getRobotNodeSet(robotNodeSetName);
74 
75  // Stop the robot
76  // build name value map
77  // NameValueMap targetVelocities;
78  //// NameValueMap targetPositions;
79  // NameControlModeMap controlModes;
80  // const std::vector< VirtualRobot::RobotNodePtr > nodes = robotNodeSet->getAllRobotNodes();
81  // std::vector< VirtualRobot::RobotNodePtr >::const_iterator iter = nodes.begin();
82  // while (iter != nodes.end())
83  // {
84  // targetVelocities.insert(std::make_pair((*iter)->getName(), 0.0f));
85  // controlModes.insert(std::make_pair((*iter)->getName(), eVelocityControl));
86  // iter++;
87  // };
88  // // execute velocities
89  // visualServoContext->kinematicUnitPrx->switchControlMode(controlModes);
90  // visualServoContext->kinematicUnitPrx->setJointVelocities(targetVelocities);
91 
92 
94  //removeCondition(condObjectLost); //TODO (maybe): move this to the VSExample (where the condObjectUpdate also is)
96 
97  ARMARX_VERBOSE << "Done VisualServo::onExit()";
98 }
99 
100 // DO NOT EDIT NEXT FUNCTION
101 std::string VisualServo::GetName()
102 {
103  return "VisualServo";
104 }
105 
106 // DO NOT EDIT NEXT FUNCTION
108 {
109  return XMLStateFactoryBasePtr(new VisualServo(stateData));
110 }
111 
armarx::StateUtility::removeCondition
void removeCondition(ConditionIdentifier conditionId)
Utility function to remove an installed condition on the distributed conditionhandler.
Definition: StateUtil.cpp:131
ARMARX_VERBOSE
#define ARMARX_VERBOSE
Definition: Logging.h:180
armarx::FindAndGraspObjectGroup::VisualServo
Definition: VisualServo.h:33
ARMARX_IMPORTANT
#define ARMARX_IMPORTANT
Definition: Logging.h:183
armarx::FindAndGraspObjectGroup::VisualServo::Registry
static SubClassRegistry Registry
Definition: VisualServo.h:47
armarx::FindAndGraspObjectGroup::VisualServo::VisualServo
VisualServo(XMLStateConstructorParams stateData)
Definition: VisualServo.cpp:35
armarx::FindAndGraspObjectGroup::VisualServo::onEnter
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
Definition: VisualServo.cpp:40
armarx::XMLStateConstructorParams
Definition: XMLState.h:50
armarx::FindAndGraspObjectGroup::VisualServo::CreateInstance
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Definition: VisualServo.cpp:107
armarx::Literal::createParameterList
static VarList createParameterList()
Static helper method to create an empty parameterlist.
Definition: Term.cpp:129
IceInternal::Handle< ChannelRef >
armarx::StateUtility::setTimeoutEvent
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
Definition: StateUtil.cpp:144
armarx::XMLStateTemplate
Class for legacy to stay compatible with old statecharts.
Definition: XMLState.h:137
armarx::FindAndGraspObjectGroup::VisualServo::onExit
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
Definition: VisualServo.cpp:66
armarx::StateUtility::installCondition
ConditionIdentifier installCondition(const Term &condition, const EventPtr evt, const std::string &desc="")
Utility function to install a condition on the distributed conditionhandler.
Definition: StateUtil.cpp:97
armarx::FindAndGraspObjectGroup::VisualServo::condMarkerLost
ConditionIdentifier condMarkerLost
Definition: VisualServo.h:53
VisualServo.h
armarx::XMLStateFactoryBasePtr
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition: XMLState.h:65
armarx::FindAndGraspObjectGroup::VisualServo::GetName
static std::string GetName()
Definition: VisualServo.cpp:101
armarx::Literal
Definition: Term.h:208
armarx::FindAndGraspObjectGroup::VisualServo::condServoTimeout
ActionEventIdentifier condServoTimeout
Definition: VisualServo.h:52
armarx::StateUtility::removeTimeoutEvent
void removeTimeoutEvent(const ActionEventIdentifier &id)
Definition: StateUtil.cpp:178
armarx
This file offers overloads of toIce() and fromIce() functions for STL container types.
Definition: ArmarXTimeserver.cpp:28