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
27using namespace armarx;
28using namespace FindAndGraspObjectGroup;
29
30// DO NOT EDIT NEXT LINE
31VisualServo::SubClassRegistry VisualServo::Registry(VisualServo::GetName(),
33
38
39void
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"),
61 "smaller",
62 Literal::createParameterList(minRecognitionLikelihood));
64
65 ARMARX_IMPORTANT << "Done VisualServo::onEnter()";
66}
67
68void
70{
71 // VisualServoContext* visualServoContext = getContext<VisualServoContext>();
72
73 // std::string robotNodeSetName = getInput<std::string>("kinematicChain");
74 // VirtualRobot::RobotPtr localRobot = RemoteRobot::createLocalClone(visualServoContext->robotStateComponent);
75 // VirtualRobot::RobotNodeSetPtr robotNodeSet = visualServoContext->remoteRobot->getRobotNodeSet(robotNodeSetName);
76 // VirtualRobot::RobotNodeSetPtr robotNodeSet = localRobot->getRobotNodeSet(robotNodeSetName);
77
78 // Stop the robot
79 // build name value map
80 // NameValueMap targetVelocities;
81 //// NameValueMap targetPositions;
82 // NameControlModeMap controlModes;
83 // const std::vector< VirtualRobot::RobotNodePtr > nodes = robotNodeSet->getAllRobotNodes();
84 // std::vector< VirtualRobot::RobotNodePtr >::const_iterator iter = nodes.begin();
85 // while (iter != nodes.end())
86 // {
87 // targetVelocities.insert(std::make_pair((*iter)->getName(), 0.0f));
88 // controlModes.insert(std::make_pair((*iter)->getName(), eVelocityControl));
89 // iter++;
90 // };
91 // // execute velocities
92 // visualServoContext->kinematicUnitPrx->switchControlMode(controlModes);
93 // visualServoContext->kinematicUnitPrx->setJointVelocities(targetVelocities);
94
95
97 //removeCondition(condObjectLost); //TODO (maybe): move this to the VSExample (where the condObjectUpdate also is)
99
100 ARMARX_VERBOSE << "Done VisualServo::onExit()";
101}
102
103// DO NOT EDIT NEXT FUNCTION
104std::string
106{
107 return "VisualServo";
108}
109
110// DO NOT EDIT NEXT FUNCTION
VisualServo(XMLStateConstructorParams stateData)
void onEnter() override
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden,...
void onExit() override
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden,...
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData)
Literals are part of the user front end of the ArmarX condition mechanism.
Definition Term.h:209
static VarList createParameterList()
Static helper method to create an empty parameterlist.
Definition Term.cpp:142
void removeCondition(ConditionIdentifier conditionId)
Utility function to remove an installed condition on the distributed conditionhandler.
void removeTimeoutEvent(const ActionEventIdentifier &id)
ActionEventIdentifier setTimeoutEvent(int timeoutDurationMs, const EventPtr &evt)
Utility function to start a timer on the systemObserver and register an event on the conditionHandler...
EventPtr createEvent()
Utility function to create a new Event.
Definition StateUtil.h:63
ConditionIdentifier installCondition(const Term &condition, const EventPtr evt, const std::string &desc="")
Utility function to install a condition on the distributed conditionhandler.
std::enable_if_t< std::is_base_of_v< VariantDataClass, T >, IceInternal::Handle< T > > getInput(const std::string &key) const
getInput can be used to access a specific input parameter.
Definition State.h:620
XMLStateTemplate(const XMLStateConstructorParams &params)
Definition XMLState.h:149
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
Definition Logging.h:190
#define ARMARX_VERBOSE
The logging level for verbose information.
Definition Logging.h:187
This file offers overloads of toIce() and fromIce() functions for STL container types.
IceInternal::Handle< ChannelRef > ChannelRefPtr
Definition ChannelRef.h:40
IceInternal::Handle< XMLStateFactoryBase > XMLStateFactoryBasePtr
Definition XMLState.h:64