From bf4e00b0b62b010ed75cb2493b20d145c91af40f Mon Sep 17 00:00:00 2001 From: Mirko Waechter <mirko.waechter@kit.edu> Date: Tue, 24 May 2016 14:40:10 +0200 Subject: [PATCH] extended create local clone functions --- .../libraries/core/remoterobot/RemoteRobot.cpp | 15 +++++++++++---- .../libraries/core/remoterobot/RemoteRobot.h | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp b/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp index 1afddfda3..fa4636b56 100644 --- a/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp +++ b/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.cpp @@ -327,12 +327,12 @@ namespace armarx return robo; } - VirtualRobot::RobotPtr RemoteRobot::createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const string& filename, const Ice::StringSeq packages) + VirtualRobot::RobotPtr RemoteRobot::createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const string& filename, const Ice::StringSeq packages, VirtualRobot::RobotIO::RobotDescription loadMode) { - return createLocalClone(robotStatePrx->getSynchronizedRobot(), filename, robotStatePrx->getScaling(), packages); + return createLocalClone(robotStatePrx->getSynchronizedRobot(), filename, robotStatePrx->getScaling(), packages, loadMode); } - RobotPtr RemoteRobot::createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, std::string filename, float scaling, const Ice::StringSeq packages) + RobotPtr RemoteRobot::createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, std::string filename, float scaling, const Ice::StringSeq packages, VirtualRobot::RobotIO::RobotDescription loadMode) { RobotPtr result; @@ -386,7 +386,7 @@ namespace armarx ARMARX_ERROR_S << "Could find robot file " << filename; return result; } - result = RobotIO::loadRobot(filename); + result = RobotIO::loadRobot(filename, loadMode); if (!result) { @@ -405,6 +405,13 @@ namespace armarx return result; } + RobotPtr RemoteRobot::createLocalCloneFromFile(RobotStateComponentInterfacePrx robotStatePrx, RobotIO::RobotDescription loadMode) + { + return createLocalClone(robotStatePrx, robotStatePrx->getRobotFilename(), robotStatePrx->getArmarXPackages(), loadMode); + } + + + bool RemoteRobot::synchronizeLocalClone(VirtualRobot::RobotPtr robot, RobotStateComponentInterfacePrx robotStatePrx) { return synchronizeLocalClone(robot, robotStatePrx->getSynchronizedRobot()); diff --git a/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.h b/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.h index c4a6134fc..6d9b69c8a 100644 --- a/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.h +++ b/source/RobotAPI/libraries/core/remoterobot/RemoteRobot.h @@ -28,6 +28,7 @@ #include <VirtualRobot/VirtualRobot.h> #include <VirtualRobot/Robot.h> +#include <VirtualRobot/XML/RobotIO.h> #include <VirtualRobot/RobotNodeSet.h> #include <VirtualRobot/Nodes/RobotNode.h> #include <VirtualRobot/Nodes/RobotNodeRevolute.h> @@ -184,10 +185,22 @@ namespace armarx In order to get a fully featured robot model you can pass a filename to VirtualRobot::Robot, but then you need to make sure that the loaded model is identical to the model of the remote robot (otherwise errors will occur). In the packages parameter you can pass in ArmarX packages, in which the robot file model might be in. + The loadMode specifies in which mode the model should be loaded. Refer to simox for more information (only matters if filename was passed in). + @see createLocalCloneFromFile(), synchronizeLocalClone() */ - static VirtualRobot::RobotPtr createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const std::string& filename = std::string(), const Ice::StringSeq packages = Ice::StringSeq()); + static VirtualRobot::RobotPtr createLocalClone(RobotStateComponentInterfacePrx robotStatePrx, const std::string& filename = std::string(), const Ice::StringSeq packages = Ice::StringSeq(), VirtualRobot::RobotIO::RobotDescription loadMode = VirtualRobot::RobotIO::eFull); + + static VirtualRobot::RobotPtr createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, std::string filename = std::string(), float scaling = 1.0f, const Ice::StringSeq packages = Ice::StringSeq(), VirtualRobot::RobotIO::RobotDescription loadMode = VirtualRobot::RobotIO::eFull); + + /** + * @brief This is a convenience function for createLocalClone, which automatically get the filename from the RobotStateComponent, loads robot from the file and syncs it once. + * @param robotStatePrx proxy to the RobotStateComponent + * @param loadMode he loadMode specifies in which mode the model should be loaded. Refer to simox for more information. + * @return new robot clone + * @see createLocalClone(), synchronizeLocalClone() + */ + static VirtualRobot::RobotPtr createLocalCloneFromFile(RobotStateComponentInterfacePrx robotStatePrx, VirtualRobot::RobotIO::RobotDescription loadMode = VirtualRobot::RobotIO::eFull); - static VirtualRobot::RobotPtr createLocalClone(SharedRobotInterfacePrx sharedRobotPrx, std::string filename = std::string(), float scaling = 1.0f, const Ice::StringSeq packages = Ice::StringSeq()); /*! Use this method to synchronize (i.e. copy the joint values) from the remote robot to the local clone. -- GitLab