Skip to content
Snippets Groups Projects
Commit 516074d3 authored by Raphael Grimm's avatar Raphael Grimm
Browse files

Add MultiHandUnit

It bundles multiple HandUnits and provides access to them via name.
This makes HandUnits usable in statecharts
parent 9445a577
No related branches found
No related tags found
No related merge requests found
Showing
with 351 additions and 2 deletions
......@@ -267,5 +267,14 @@
propertyName="FrameTrackingName"
propertyIsOptional="true"
propertyDefaultValue="FrameTracking" />
<Proxy include="RobotAPI/interface/units/MultiHandUnitInterface.h"
humanName="MultiHandUnit"
typeName="MultiHandUnitInterfacePrx"
memberName="multiHandUnit"
getterName="getMultiHandUnit"
propertyName="MultiHandUnitName"
propertyIsOptional="true"
propertyDefaultValue="MultiHandUnit" />
</Lib>
</VariantInfo>
......@@ -47,4 +47,6 @@ add_subdirectory(GraspCandidateObserver)
add_subdirectory(FrameTracking)
add_subdirectory(KITHandUnit)
\ No newline at end of file
add_subdirectory(KITHandUnit)
add_subdirectory(MultiHandUnit)
armarx_component_set_name("MultiHandUnitApp")
set(COMPONENT_LIBS MultiHandUnit)
armarx_add_component_executable(main.cpp)
#find_package(MyLib QUIET)
#armarx_build_if(MyLib_FOUND "MyLib not available")
# all target_include_directories must be guarded by if(Xyz_FOUND)
# for multiple libraries write: if(X_FOUND AND Y_FOUND)....
#if(MyLib_FOUND)
# target_include_directories(MultiHandUnit PUBLIC ${MyLib_INCLUDE_DIRS})
#endif()
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::application::MultiHandUnit
* @author Raphael Grimm ( raphael dot grimm at kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include <RobotAPI/components/MultiHandUnit/MultiHandUnit.h>
#include <ArmarXCore/core/application/Application.h>
#include <ArmarXCore/core/Component.h>
#include <ArmarXCore/core/logging/Logging.h>
int main(int argc, char* argv[])
{
return armarx::runSimpleComponentApp < armarx::MultiHandUnit > (argc, argv, "MultiHandUnit");
}
......@@ -11,4 +11,6 @@ add_subdirectory(CyberGloveObserver)
add_subdirectory(RobotHealth)
add_subdirectory(FrameTracking)
add_subdirectory(KITHandUnit)
\ No newline at end of file
add_subdirectory(KITHandUnit)
add_subdirectory(MultiHandUnit)
armarx_component_set_name("MultiHandUnit")
set(COMPONENT_LIBS
ArmarXCore
RobotAPICore
)
set(SOURCES MultiHandUnit.cpp)
set(HEADERS MultiHandUnit.h)
armarx_add_component("${SOURCES}" "${HEADERS}")
# add unit tests
add_subdirectory(test)
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::MultiHandUnit
* @author Raphael Grimm ( raphael dot grimm at kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#include "MultiHandUnit.h"
namespace armarx
{
MultiHandUnitPropertyDefinitions::MultiHandUnitPropertyDefinitions(std::string prefix) :
armarx::ComponentPropertyDefinitions(prefix)
{
defineOptionalProperty<std::string>("HandUnitNameCSV", "", "");
}
std::string MultiHandUnit::getDefaultName() const
{
return "MultiHandUnit";
}
void MultiHandUnit::onInitComponent()
{
const auto units = getPropertyAsCSV<std::string>("HandUnitNameCSV");
if (units.empty())
{
ARMARX_ERROR << "PROPERTY HandUnitNameCSV IS EMPTY";
}
_handInfos.reserve(units.size());
for (const auto& name : units)
{
_handInfos.emplace_back();
_handInfos.back().proxyName = name;
usingProxy(name);
}
}
void MultiHandUnit::onConnectComponent()
{
for (auto& info : _handInfos)
{
getProxy(info.proxy, info.proxyName);
info.handName = info.proxy->getHandName();
_hands[info.handName] = info.proxy;
}
}
void MultiHandUnit::onDisconnectComponent()
{
_hands.clear();
}
void MultiHandUnit::onExitComponent()
{
}
armarx::PropertyDefinitionsPtr MultiHandUnit::createPropertyDefinitions()
{
return armarx::PropertyDefinitionsPtr(new MultiHandUnitPropertyDefinitions(
getConfigIdentifier()));
}
HandInfoSeq MultiHandUnit::getHandInfos(const Ice::Current&)
{
return _handInfos;
}
void MultiHandUnit::setJointValues(const std::string& handName, const NameValueMap& jointValues, const Ice::Current&)
{
_hands.at(handName)->setJointAngles(jointValues);
}
NameValueMap MultiHandUnit::getJointValues(const std::string& handName, const Ice::Current&)
{
return _hands.at(handName)->getCurrentJointValues();
}
}
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::MultiHandUnit
* @author Raphael Grimm ( raphael dot grimm at kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <ArmarXCore/core/Component.h>
#include <RobotAPI/interface/units/MultiHandUnitInterface.h>
namespace armarx
{
/**
* @class MultiHandUnitPropertyDefinitions
* @brief
*/
class MultiHandUnitPropertyDefinitions :
public armarx::ComponentPropertyDefinitions
{
public:
MultiHandUnitPropertyDefinitions(std::string prefix);
};
/**
* @defgroup Component-MultiHandUnit MultiHandUnit
* @ingroup RobotAPI-Components
* A description of the component MultiHandUnit.
*
* @class MultiHandUnit
* @ingroup Component-MultiHandUnit
* @brief Brief description of class MultiHandUnit.
*
* Detailed description of class MultiHandUnit.
*/
class MultiHandUnit :
virtual public armarx::Component,
virtual public MultiHandUnitInterface
{
public:
/// @see armarx::ManagedIceObject::getDefaultName()
virtual std::string getDefaultName() const override;
protected:
/// @see armarx::ManagedIceObject::onInitComponent()
virtual void onInitComponent() override;
/// @see armarx::ManagedIceObject::onConnectComponent()
virtual void onConnectComponent() override;
/// @see armarx::ManagedIceObject::onDisconnectComponent()
virtual void onDisconnectComponent() override;
/// @see armarx::ManagedIceObject::onExitComponent()
virtual void onExitComponent() override;
/// @see PropertyUser::createPropertyDefinitions()
virtual armarx::PropertyDefinitionsPtr createPropertyDefinitions() override;
HandInfoSeq getHandInfos(const Ice::Current& = Ice::emptyCurrent) override;
void setJointValues(const std::string& handName, const NameValueMap& jointValues, const Ice::Current& = Ice::emptyCurrent) override;
NameValueMap getJointValues(const std::string& handName, const Ice::Current& = Ice::emptyCurrent) override;
private:
HandInfoSeq _handInfos;
std::map<std::string, HandUnitInterfacePrx> _hands;
};
}
# Libs required for the tests
SET(LIBS ${LIBS} ArmarXCore MultiHandUnit)
armarx_add_test(MultiHandUnitTest MultiHandUnitTest.cpp "${LIBS}")
/*
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI::ArmarXObjects::MultiHandUnit
* @author Raphael Grimm ( raphael dot grimm at kit dot edu )
* @date 2019
* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#define BOOST_TEST_MODULE RobotAPI::ArmarXObjects::MultiHandUnit
#define ARMARX_BOOST_TEST
#include <RobotAPI/Test.h>
#include <RobotAPI/components/MultiHandUnit/MultiHandUnit.h>
#include <iostream>
BOOST_AUTO_TEST_CASE(testExample)
{
armarx::MultiHandUnit instance;
BOOST_CHECK_EQUAL(true, true);
}
......@@ -27,6 +27,7 @@ set(SLICE_FILES
observers/SpeechObserverInterface.ice
observers/GraspCandidateObserverInterface.ice
units/MultiHandUnitInterface.ice
units/ForceTorqueUnit.ice
units/InertialMeasurementUnit.ice
units/OptoForceUnit.ice
......
/**
* This file is part of ArmarX.
*
* ArmarX is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* ArmarX is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
* @package RobotAPI
* @author Simon Ottenhaus
* @copyright 2019 Humanoids Group, H2T, KIT
* @license http://www.gnu.org/licenses/gpl-2.0.txt
* GNU General Public License
*/
#pragma once
#include <ArmarXCore/interface/core/BasicTypes.ice>
#include <RobotAPI/interface/units/HandUnitInterface.ice>
module armarx
{
struct HandInfo
{
HandUnitInterface* proxy;
//string handType;
string proxyName;
string handName;
//Ice::StringSeq jointNames;
};
sequence<HandInfo> HandInfoSeq;
interface MultiHandUnitInterface
{
HandInfoSeq getHandInfos();
void setJointValues(string handName, NameValueMap jointValues);
NameValueMap getJointValues(string handName);
};
};
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment