diff --git a/data/RobotAPI/robots/Armar3/ArmarIII.xml b/data/RobotAPI/robots/Armar3/ArmarIII.xml index f782c5bb4fcfb9c923b00a05b1356b7ba3590eb9..5a09f5d28c11a36a69fd506028966d9ea5f1afa1 100644 --- a/data/RobotAPI/robots/Armar3/ArmarIII.xml +++ b/data/RobotAPI/robots/Armar3/ArmarIII.xml @@ -493,6 +493,19 @@ <Node name="Eye_Left"/> <Node name="HeadMotionMeasurementTCP"/> </RobotNodeSet> - + + <RobotInfo> + <KinematicChains> + <LeftArm value="LeftArm" /> + <RightArm value="RightArm" /> + <LeftArmTCP value="TCP L" /> + <RightArmTCP value="TCP R" /> + <TorsoLeftArm value="HipYawLeftArm" /> + <TorsoRightArm value="HipYawRightArm" /> + </KinematicChains> + + <test value="abc" /> + <test profile="Armar3Simulation" value="abc_sim" /> + </RobotInfo> </Robot> diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp index 773e0d03b988906d5dd64344faac91ff10485b65..f9072fedc91dcb0b42e5e7f032371dcd4292e6fc 100644 --- a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp +++ b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp @@ -33,6 +33,7 @@ #include <ArmarXCore/core/ArmarXManager.h> #include <ArmarXCore/core/ArmarXObjectScheduler.h> #include <ArmarXCore/core/application/Application.h> +#include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> using namespace std; using namespace VirtualRobot; @@ -119,6 +120,8 @@ namespace armarx } usingTopic(robotNodeSetName + "State"); + readRobotInfo(robotFile); + /*VirtualRobot::RobotNodeSetPtr pns = this->_synchronized->getRobotNodeSet("Platform"); if (pns) @@ -134,6 +137,27 @@ namespace armarx }*/ } + void RobotStateComponent::readRobotInfo(const std::string& robotFile) + { + RapidXmlReaderPtr reader = RapidXmlReader::FromFile(robotFile); + RapidXmlReaderNode robotNode = reader->getRoot("Robot"); + robotInfo = readRobotInfo(robotNode.first_node("RobotInfo")); + } + + RobotInfoNodePtr RobotStateComponent::readRobotInfo(const RapidXmlReaderNode& infoNode) + { + std::string name = infoNode.name(); + std::string profile = infoNode.attribute_value_or_default("profile", ""); + std::string value = infoNode.attribute_value_or_default("value", ""); + //ARMARX_IMPORTANT << "name: " << name << "; profile: " << profile << "; value: " << value; + std::vector<RobotInfoNodePtr> children; + for(const RapidXmlReaderNode& childNode : infoNode.nodes()) + { + children.push_back(readRobotInfo(childNode)); + } + return new RobotInfoNode(name, profile, value, children); + } + void RobotStateComponent::onConnectComponent() { @@ -347,6 +371,11 @@ namespace armarx return robotModelScaling; } + RobotInfoNodePtr RobotStateComponent::getRobotInfo(const Ice::Current&) const + { + return robotInfo; + } + std::vector<string> RobotStateComponent::getArmarXPackages(const Current&) const { std::vector<string> result; @@ -422,9 +451,3 @@ namespace armarx return robotStateTopicName; } } - - - - - - diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.h b/source/RobotAPI/components/RobotState/RobotStateComponent.h index 95b5680f2e07aa2d22e5059e930d52da7223551b..817743c6d9c4ccc5e1ae79af641afc7a0c6df5dd 100644 --- a/source/RobotAPI/components/RobotState/RobotStateComponent.h +++ b/source/RobotAPI/components/RobotState/RobotStateComponent.h @@ -36,6 +36,8 @@ #include <RobotAPI/libraries/core/remoterobot/RobotStateObserver.h> +#include <ArmarXCore/core/rapidxml/wrapper/RapidXmlReader.h> + namespace armarx { /** @@ -141,6 +143,9 @@ namespace armarx bool interpolate(double time, RobotStateConfig& config) const; float getScaling(const Ice::Current&) const override; + + RobotInfoNodePtr getRobotInfo(const Ice::Current&) const override; + protected: /** * Load and create a VirtualRobot::Robot instance from the RobotFileName @@ -167,7 +172,11 @@ namespace armarx void reportJointCurrents(const NameValueMap& jointCurrents, Ice::Long timestamp, bool aValueChanged, const Ice::Current& c = ::Ice::Current()) override; void reportJointMotorTemperatures(const NameValueMap& jointMotorTemperatures, Ice::Long timestamp, bool aValueChanged, const Ice::Current& c = ::Ice::Current()) override; void reportJointStatuses(const NameStatusMap& jointStatuses, Ice::Long timestamp, bool aValueChanged, const Ice::Current& c = ::Ice::Current()) override; + private: + void readRobotInfo(const std::string& robotFile); + RobotInfoNodePtr readRobotInfo(const RapidXmlReaderNode& infoNode); + SharedRobotInterfacePrx _synchronizedPrx; SharedRobotServantPtr _sharedRobotServant; VirtualRobot::RobotPtr _synchronized; @@ -185,6 +194,7 @@ namespace armarx float robotModelScaling; + RobotInfoNodePtr robotInfo; }; } diff --git a/source/RobotAPI/interface/components/RobotNameServiceInterface.ice b/source/RobotAPI/interface/components/RobotNameServiceInterface.ice index 6c8026c72e93223a383bbd9c3cfe8678b49f90d4..ee0d94b95bb6f23b3e99cc9bb175dab644bbdb3c 100644 --- a/source/RobotAPI/interface/components/RobotNameServiceInterface.ice +++ b/source/RobotAPI/interface/components/RobotNameServiceInterface.ice @@ -13,14 +13,12 @@ * 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::TrajectoryControllerSubUnit - * @author Stefan Reither ( stef dot reither at web dot de ) - * @date 2017 + * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu ) + * @date 2018 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt * GNU General Public License */ -#include <RobotAPI/interface/core/Trajectory.ice> #include <RobotAPI/interface/observers/KinematicUnitObserverInterface.ice> #ifndef _ARMARX_ROBOTAPI_COMPONENTS_ROBOT_NAME_SERVICE_SLICE_ diff --git a/source/RobotAPI/interface/core/RobotState.ice b/source/RobotAPI/interface/core/RobotState.ice index 593e5b2b23d454fd4ceb1d6ad23b114f698c9a52..4ae1c01d6dee2d60b0c36eba031ac79a016ab947 100644 --- a/source/RobotAPI/interface/core/RobotState.ice +++ b/source/RobotAPI/interface/core/RobotState.ice @@ -167,6 +167,15 @@ module armarx float getScaling(); }; + class RobotInfoNode; + sequence<RobotInfoNode> RobotInfoNodeList; + class RobotInfoNode + { + string name; + string profile; + string value; + RobotInfoNodeList children; + }; /** * The interface used by the RobotStateComponent which allows creating @@ -249,14 +258,20 @@ module armarx * @return The name of the robot node set that is represented by this component. * */ - ["cpp:const"] - idempotent string getRobotNodeSetName() throws NotInitializedException; + ["cpp:const"] + idempotent string getRobotNodeSetName() throws NotInitializedException; + + ["cpp:const"] + idempotent RobotInfoNode getRobotInfo(); + }; + interface RobotStateListenerInterface { void reportGlobalRobotRootPose(FramedPoseBase globalPose, long timestamp, bool poseChanged); void reportJointValues(NameValueMap jointAngles, long timestamp, bool aValueChanged); }; + }; diff --git a/source/RobotAPI/libraries/RobotStatechartHelpers/CMakeLists.txt b/source/RobotAPI/libraries/RobotStatechartHelpers/CMakeLists.txt index a7d4a2e9e15e6ab016dc614dd2c04b381fb5bcd6..00cfc565c1a309780e4f3e219c84de32cc658f68 100644 --- a/source/RobotAPI/libraries/RobotStatechartHelpers/CMakeLists.txt +++ b/source/RobotAPI/libraries/RobotStatechartHelpers/CMakeLists.txt @@ -18,8 +18,9 @@ if (Eigen3_FOUND AND Simox_FOUND) endif() set(COMPONENT_LIBS - ArmarXCoreInterfaces RobotAPIInterfaces RobotAPICore ${Simox_LIBRARIES} - ArmarXCore ArmarXCoreObservers + ArmarXCoreInterfaces ArmarXCore ArmarXCoreObservers ArmarXCoreStatechart + RobotAPIInterfaces RobotAPICore + ${Simox_LIBRARIES} ) set(LIB_FILES @@ -27,6 +28,7 @@ set(LIB_FILES VelocityControllerHelper.cpp PositionControllerHelper.cpp ForceTorqueHelper.cpp +RobotNameHelper.cpp #@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.cpp ) set(LIB_HEADERS @@ -34,6 +36,7 @@ set(LIB_HEADERS VelocityControllerHelper.h PositionControllerHelper.h ForceTorqueHelper.h +RobotNameHelper.h #@TEMPLATE_LINE@@COMPONENT_PATH@/@COMPONENT_NAME@.h ) diff --git a/source/RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.cpp b/source/RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.cpp new file mode 100644 index 0000000000000000000000000000000000000000..138c7ab70821c2e1900e075284b32b5f9266d176 --- /dev/null +++ b/source/RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.cpp @@ -0,0 +1,152 @@ +/* + * This file is part of ArmarX. + * + * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), + * Karlsruhe Institute of Technology (KIT), all rights reserved. + * + * 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/>. + * + * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "RobotNameHelper.h" +#include <ArmarXCore/core/util/StringHelpers.h> + +using namespace armarx; + +const std::string RobotNameHelper::LocationLeft = "Left"; +const std::string RobotNameHelper::LocationRight = "Right"; + +RobotNameHelper::RobotNameHelper(const RobotInfoNodePtr& robotInfo, const StatechartProfilePtr& profile) + : root(Node(robotInfo)), kinematicChains(self()) +{ + StatechartProfilePtr p = profile; + while(p && !p->isRoot()) + { + profiles.emplace_back(p->getName()); + p = p->getParent(); + } + profiles.emplace_back(""); // for matching the default/root + +} + +std::string RobotNameHelper::select(const std::string& path) const +{ + Node node = root; + for(const std::string& p : Split(path, "/")) + { + node = node.select(p, profiles); + } + if(!node.isValid()) + { + throw std::runtime_error("RobotNameHelper::select: path " + path + " not found"); + } + return node.value(); +} + +RobotNameHelper::Node::Node(const RobotInfoNodePtr& robotInfo) + : robotInfo(robotInfo) +{ + +} + +std::string RobotNameHelper::Node::value() +{ + checkValid(); + return robotInfo->value; +} + +RobotNameHelper::Node RobotNameHelper::Node::select(const std::string& name, const std::vector<std::string>& profiles) +{ + if(!isValid()) + { + return Node(nullptr); + } + std::map<std::string, RobotInfoNodePtr> matches; + for(const RobotInfoNodePtr& child : robotInfo->children) + { + if(child->name == name) + { + matches[child->profile] = child; + } + } + for(const std::string& p : profiles) + { + if(matches.count(p)) + { + return matches.at(p); + } + } + return Node(nullptr); +} + +bool RobotNameHelper::Node::isValid() +{ + return robotInfo ? true : false; +} + +void RobotNameHelper::Node::checkValid() +{ + if(!isValid()) + { + throw std::runtime_error("RobotNameHelper::Node nullptr exception"); + } +} + +RobotNameHelper::KinematicChains::KinematicChains(const RobotNameHelper& rnh) + : rnh(rnh) +{ + +} + +std::string RobotNameHelper::KinematicChains::getArm(const std::string& location) const +{ + return rnh.select("KinematicChains/" + location + "Arm"); +} + +std::string RobotNameHelper::KinematicChains::getLeftArm() const +{ + return getArm(LocationLeft); +} + +std::string RobotNameHelper::KinematicChains::getRightArm() const +{ + return getArm(LocationRight); +} + +std::string RobotNameHelper::KinematicChains::getTorsoLeftArm() const +{ + return getArm("Torso" + LocationLeft); +} + +std::string RobotNameHelper::KinematicChains::getTorsoRightArm() const +{ + return getArm("Torso" + LocationRight); +} + +std::string RobotNameHelper::KinematicChains::getArmTCP(const std::string& location) const +{ + return rnh.select("KinematicChains/" + location + "ArmTCP"); +} + +std::string RobotNameHelper::KinematicChains::getLeftArmTCP() const +{ + return getArmTCP(LocationLeft); +} + +std::string RobotNameHelper::KinematicChains::getRightArmTCP() const +{ + return getArmTCP(LocationRight); +} diff --git a/source/RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.h b/source/RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.h new file mode 100644 index 0000000000000000000000000000000000000000..6beaf49b9071831addef9ae184969cecd2407238 --- /dev/null +++ b/source/RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.h @@ -0,0 +1,92 @@ +/* + * This file is part of ArmarX. + * + * Copyright (C) 2012-2016, High Performance Humanoid Technologies (H2T), + * Karlsruhe Institute of Technology (KIT), all rights reserved. + * + * 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/>. + * + * @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu) + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <boost/shared_ptr.hpp> + +#include <RobotAPI/interface/core/RobotState.h> + +#include <ArmarXCore/statechart/xmlstates/profiles/StatechartProfiles.h> + +namespace armarx +{ + typedef boost::shared_ptr<class RobotNameHelper> RobotNameHelperPtr; + + class RobotNameHelper + { + public: + class Node + { + public: + Node(const RobotInfoNodePtr& robotInfo); + std::string value(); + + Node select(const std::string& name, const std::vector<std::string>& profiles); + bool isValid(); + void checkValid(); + + private: + RobotInfoNodePtr robotInfo; + }; + + static const std::string LocationLeft; + static const std::string LocationRight; + + class KinematicChains + { + public: + KinematicChains(const RobotNameHelper& rnh); + KinematicChains(KinematicChains const&) = delete; + KinematicChains& operator=(KinematicChains const&) = delete; + + std::string getArm(const std::string& location) const; + std::string getLeftArm() const; + std::string getRightArm() const; + std::string getTorsoLeftArm() const; + std::string getTorsoRightArm() const; + + std::string getArmTCP(const std::string& location) const; + std::string getLeftArmTCP() const; + std::string getRightArmTCP() const; + + + private: + const RobotNameHelper& rnh; + }; + + RobotNameHelper(const RobotInfoNodePtr& robotInfo, const StatechartProfilePtr& profile); + std::string select(const std::string& path) const; + + + private: + RobotNameHelper& self() { return *this; } + + Node root; + std::vector<std::string> profiles; + + public: + KinematicChains kinematicChains; + + }; +} diff --git a/source/RobotAPI/statecharts/CMakeLists.txt b/source/RobotAPI/statecharts/CMakeLists.txt index 57d792ac7cef38364c95c55bdb988e6ee64a8978..6916c27001b17fd2a68aad36e7aa2acbe7e0831a 100644 --- a/source/RobotAPI/statecharts/CMakeLists.txt +++ b/source/RobotAPI/statecharts/CMakeLists.txt @@ -7,4 +7,5 @@ add_subdirectory(OrientedTactileSensorGroup) add_subdirectory(TrajectoryExecutionCode) add_subdirectory(SpeechObserverTestGroup) -add_subdirectory(ForceTorqueUtility) \ No newline at end of file +add_subdirectory(ForceTorqueUtility) +add_subdirectory(RobotNameHelperTestGroup) \ No newline at end of file diff --git a/source/RobotAPI/statecharts/RobotNameHelperTestGroup/CMakeLists.txt b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..43260100dde507f36a5eb112be22dd2eed864194 --- /dev/null +++ b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/CMakeLists.txt @@ -0,0 +1,45 @@ +armarx_component_set_name("RobotNameHelperTestGroup") + +#find_package(MyLib QUIET) +#armarx_build_if(MyLib_FOUND "MyLib not available") +# +# all include_directories must be guarded by if(Xyz_FOUND) +# for multiple libraries write: if(X_FOUND AND Y_FOUND).... +#if(MyLib_FOUND) +# include_directories(${MyLib_INCLUDE_DIRS}) +#endif() + +find_package(Eigen3 QUIET) +find_package(Simox QUIET) + + +armarx_build_if(Eigen3_FOUND "Eigen3 not available") +armarx_build_if(Simox_FOUND "Simox-VirtualRobot not available") + + +if (Eigen3_FOUND AND Simox_FOUND) + include_directories( + ${Eigen3_INCLUDE_DIR} + ${Simox_INCLUDE_DIRS} + ) +endif() + +set(COMPONENT_LIBS + ArmarXCoreInterfaces RobotAPIInterfaces RobotAPICore RobotStatechartHelpers ${Simox_LIBRARIES} + ArmarXCore ArmarXCoreStatechart ArmarXCoreObservers) + +# Sources + +set(SOURCES +RobotNameHelperTestGroupRemoteStateOfferer.cpp +) + +set(HEADERS +RobotNameHelperTestGroupRemoteStateOfferer.h +RobotNameHelperTestGroup.scgxml +) + +# adds all existing state headers and sources to CMake +armarx_generate_statechart_cmake_lists() + +armarx_add_component("${SOURCES}" "${HEADERS}") diff --git a/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroup.scgxml b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroup.scgxml new file mode 100644 index 0000000000000000000000000000000000000000..b45aff5db15dabc5bc4305602a394f83035d48ec --- /dev/null +++ b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroup.scgxml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="utf-8"?> +<StatechartGroup name="RobotNameHelperTestGroup" package="RobotAPI" generateContext="true"> + <Proxies> + <Proxy value="RobotAPIInterfaces.robotStateComponent"/> + </Proxies> + <Configurations/> + <State filename="TestGetNames.xml" visibility="public"/> +</StatechartGroup> + diff --git a/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroupRemoteStateOfferer.cpp b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroupRemoteStateOfferer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..dc941cd5a065bb5f9aecdd38f9fc4ff8bb245a24 --- /dev/null +++ b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroupRemoteStateOfferer.cpp @@ -0,0 +1,66 @@ +/* + * 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::RobotNameHelperTestGroup::RobotNameHelperTestGroupRemoteStateOfferer + * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu ) + * @date 2018 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "RobotNameHelperTestGroupRemoteStateOfferer.h" + +using namespace armarx; +using namespace RobotNameHelperTestGroup; + +// DO NOT EDIT NEXT LINE +RobotNameHelperTestGroupRemoteStateOfferer::SubClassRegistry RobotNameHelperTestGroupRemoteStateOfferer::Registry(RobotNameHelperTestGroupRemoteStateOfferer::GetName(), &RobotNameHelperTestGroupRemoteStateOfferer::CreateInstance); + + + +RobotNameHelperTestGroupRemoteStateOfferer::RobotNameHelperTestGroupRemoteStateOfferer(StatechartGroupXmlReaderPtr reader) : + XMLRemoteStateOfferer < RobotNameHelperTestGroupStatechartContext > (reader) +{ +} + +void RobotNameHelperTestGroupRemoteStateOfferer::onInitXMLRemoteStateOfferer() +{ + +} + +void RobotNameHelperTestGroupRemoteStateOfferer::onConnectXMLRemoteStateOfferer() +{ + +} + +void RobotNameHelperTestGroupRemoteStateOfferer::onExitXMLRemoteStateOfferer() +{ + +} + +// DO NOT EDIT NEXT FUNCTION +std::string RobotNameHelperTestGroupRemoteStateOfferer::GetName() +{ + return "RobotNameHelperTestGroupRemoteStateOfferer"; +} + +// DO NOT EDIT NEXT FUNCTION +XMLStateOffererFactoryBasePtr RobotNameHelperTestGroupRemoteStateOfferer::CreateInstance(StatechartGroupXmlReaderPtr reader) +{ + return XMLStateOffererFactoryBasePtr(new RobotNameHelperTestGroupRemoteStateOfferer(reader)); +} + + + diff --git a/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroupRemoteStateOfferer.h b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroupRemoteStateOfferer.h new file mode 100644 index 0000000000000000000000000000000000000000..dccee70890542c79c6dd9bf112d1de988e662fa5 --- /dev/null +++ b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/RobotNameHelperTestGroupRemoteStateOfferer.h @@ -0,0 +1,52 @@ +/* + * 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::RobotNameHelperTestGroup + * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu ) + * @date 2018 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <ArmarXCore/statechart/xmlstates/XMLRemoteStateOfferer.h> +#include "RobotNameHelperTestGroupStatechartContext.generated.h" + +namespace armarx +{ + namespace RobotNameHelperTestGroup + { + class RobotNameHelperTestGroupRemoteStateOfferer : + virtual public XMLRemoteStateOfferer < RobotNameHelperTestGroupStatechartContext > // Change this statechart context if you need another context (dont forget to change in the constructor as well) + { + public: + RobotNameHelperTestGroupRemoteStateOfferer(StatechartGroupXmlReaderPtr reader); + + // inherited from RemoteStateOfferer + void onInitXMLRemoteStateOfferer() override; + void onConnectXMLRemoteStateOfferer() override; + void onExitXMLRemoteStateOfferer() override; + + // static functions for AbstractFactory Method + static std::string GetName(); + static XMLStateOffererFactoryBasePtr CreateInstance(StatechartGroupXmlReaderPtr reader); + static SubClassRegistry Registry; + + + }; + } +} + diff --git a/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.cpp b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.cpp new file mode 100644 index 0000000000000000000000000000000000000000..594e8b15864a7d6d200b60136a7eda6e46095f91 --- /dev/null +++ b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.cpp @@ -0,0 +1,71 @@ +/* + * 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::RobotNameHelperTestGroup + * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu ) + * @date 2018 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "TestGetNames.h" + +#include <RobotAPI/libraries/RobotStatechartHelpers/RobotNameHelper.h> + +//#include <ArmarXCore/core/time/TimeUtil.h> +//#include <ArmarXCore/observers/variant/DatafieldRef.h> + +using namespace armarx; +using namespace RobotNameHelperTestGroup; + +// DO NOT EDIT NEXT LINE +TestGetNames::SubClassRegistry TestGetNames::Registry(TestGetNames::GetName(), &TestGetNames::CreateInstance); + + + +void TestGetNames::onEnter() +{ + // put your user code for the enter-point here + // execution time should be short (<100ms) +} + +void TestGetNames::run() +{ + RobotNameHelper rnh(getRobotStateComponent()->getRobotInfo(), getSelectedProfile()); + ARMARX_IMPORTANT << "LeftArm: " << rnh.kinematicChains.getLeftArm(); + ARMARX_IMPORTANT << "LeftArm TCP: " << rnh.kinematicChains.getLeftArmTCP(); + + +} + +//void TestGetNames::onBreak() +//{ +// // put your user code for the breaking point here +// // execution time should be short (<100ms) +//} + +void TestGetNames::onExit() +{ + // put your user code for the exit point here + // execution time should be short (<100ms) +} + + +// DO NOT EDIT NEXT FUNCTION +XMLStateFactoryBasePtr TestGetNames::CreateInstance(XMLStateConstructorParams stateData) +{ + return XMLStateFactoryBasePtr(new TestGetNames(stateData)); +} + diff --git a/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.h b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.h new file mode 100644 index 0000000000000000000000000000000000000000..84b0ac8e9aa28864655f75982b33f3068d0ce20e --- /dev/null +++ b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.h @@ -0,0 +1,56 @@ +/* + * 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::RobotNameHelperTestGroup + * @author Simon Ottenhaus ( simon dot ottenhaus at kit dot edu ) + * @date 2018 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ +#pragma once + +#include <RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.generated.h> + +namespace armarx +{ + namespace RobotNameHelperTestGroup + { + class TestGetNames : + public TestGetNamesGeneratedBase < TestGetNames > + { + public: + TestGetNames(const XMLStateConstructorParams& stateData): + XMLStateTemplate < TestGetNames > (stateData), TestGetNamesGeneratedBase < TestGetNames > (stateData) + { + } + + // inherited from StateBase + void onEnter() override; + void run() override; + // void onBreak() override; + void onExit() override; + + // static functions for AbstractFactory Method + static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData); + static SubClassRegistry Registry; + + // DO NOT INSERT ANY CLASS MEMBERS, + // use stateparameters instead, + // if classmember are neccessary nonetheless, reset them in onEnter + }; + } +} + + diff --git a/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.xml b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.xml new file mode 100644 index 0000000000000000000000000000000000000000..d1a1e8ab732a1257f9ba9e98b7188e5503bc2dc3 --- /dev/null +++ b/source/RobotAPI/statecharts/RobotNameHelperTestGroup/TestGetNames.xml @@ -0,0 +1,14 @@ +<?xml version="1.0" encoding="utf-8"?> +<State version="1.2" name="TestGetNames" uuid="E97262BA-9280-43A4-844F-215F4A0614ED" width="800" height="600" type="Normal State"> + <InputParameters/> + <OutputParameters/> + <LocalParameters/> + <Substates/> + <Events> + <Event name="Failure"> + <Description>Event for statechart-internal failures or optionally user-code failures</Description> + </Event> + </Events> + <Transitions/> +</State> +