diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp index 697a5c50c01f83a36eb9de3108ae183809eedf93..de0dde42b8e8670e6c3953405ad59993eca07460 100644 --- a/source/RobotAPI/components/RobotState/RobotStateComponent.cpp +++ b/source/RobotAPI/components/RobotState/RobotStateComponent.cpp @@ -116,7 +116,7 @@ namespace armarx { ARMARX_VERBOSE << "Node: " << node->getName() << endl; } - usingTopic(robotNodeSetName + "State"); + usingTopic(getProperty<std::string>("TopicPrefix").getValue() + robotNodeSetName + "State"); try { diff --git a/source/RobotAPI/components/RobotState/RobotStateComponent.h b/source/RobotAPI/components/RobotState/RobotStateComponent.h index 10f5224dccbbab571f1540c0ecc459b249f83251..661b9d3375240cf2d83e51f1b57819315dd574f5 100644 --- a/source/RobotAPI/components/RobotState/RobotStateComponent.h +++ b/source/RobotAPI/components/RobotState/RobotStateComponent.h @@ -57,6 +57,8 @@ namespace armarx defineOptionalProperty<std::string>("RobotStateReportingTopic", "RobotStateUpdates", "Name of the topic on which updates of the robot state are reported."); defineOptionalProperty<int>("HistoryLength", 10000, "Number of entries in the robot state history"); defineOptionalProperty<float>("RobotModelScaling", 1.0f, "Scaling of the robot model"); + defineOptionalProperty<std::string>("TopicPrefix", "", "Prefix for the sensor value topic name."); + } }; diff --git a/source/RobotAPI/components/units/KinematicUnit.cpp b/source/RobotAPI/components/units/KinematicUnit.cpp index 085b96d83e2f8c67c9a522effc037d981096922f..0348c59145cf662d46e8d3b17bab1be247e8bb89 100644 --- a/source/RobotAPI/components/units/KinematicUnit.cpp +++ b/source/RobotAPI/components/units/KinematicUnit.cpp @@ -99,7 +99,7 @@ void KinematicUnit::onInitComponent() robotNodes = robotNodeSetPtr->getAllRobotNodes(); // component dependencies - listenerName = robotNodeSetName + "State"; + listenerName = getProperty<std::string>("TopicPrefix").getValue() + robotNodeSetName + "State"; offeringTopic(listenerName); this->onInitKinematicUnit(); diff --git a/source/RobotAPI/components/units/KinematicUnit.h b/source/RobotAPI/components/units/KinematicUnit.h index 40be0bf28f23c852c778ea866405f3a84ee1e5a2..67b896fc0f4640ecf5c276afa68104184bc17b14 100644 --- a/source/RobotAPI/components/units/KinematicUnit.h +++ b/source/RobotAPI/components/units/KinematicUnit.h @@ -51,6 +51,7 @@ namespace armarx defineRequiredProperty<std::string>("RobotNodeSetName", "Robot node set name as defined in robot xml file, e.g. 'LeftArm'"); defineRequiredProperty<std::string>("RobotFileName", "Robot file name, e.g. robot_model.xml"); defineOptionalProperty<std::string>("RobotFileNameProject", "", "Project in which the robot filename is located (if robot is loaded from an external project)"); + defineOptionalProperty<std::string>("TopicPrefix", "", "Prefix for the sensor value topic name."); } }; diff --git a/source/RobotAPI/components/units/KinematicUnitObserver.cpp b/source/RobotAPI/components/units/KinematicUnitObserver.cpp index 3f8f026aa8a44e9e27158c132940720683d15045..ea9b8da615bdeaccbb5cd505caf8f528ef40241a 100644 --- a/source/RobotAPI/components/units/KinematicUnitObserver.cpp +++ b/source/RobotAPI/components/units/KinematicUnitObserver.cpp @@ -56,7 +56,7 @@ void KinematicUnitObserver::onInitObserver() offerConditionCheck("larger", new ConditionCheckLarger()); offerConditionCheck("smaller", new ConditionCheckSmaller()); - usingTopic(robotNodeSetName + "State"); + usingTopic(getProperty<std::string>("TopicPrefix").getValue() + robotNodeSetName + "State"); } void KinematicUnitObserver::onConnectObserver() diff --git a/source/RobotAPI/components/units/KinematicUnitObserver.h b/source/RobotAPI/components/units/KinematicUnitObserver.h index 43eb7c0f8fe54e672a450a221667cae62546e959..92cf7f72095ebbe825087379ad1c662cc0e0cc7f 100644 --- a/source/RobotAPI/components/units/KinematicUnitObserver.h +++ b/source/RobotAPI/components/units/KinematicUnitObserver.h @@ -48,6 +48,8 @@ namespace armarx defineRequiredProperty<std::string>("RobotNodeSetName", "Robot node set name as defined in robot xml file, e.g. 'LeftArm'"); defineRequiredProperty<std::string>("RobotFileName", "Robot file name, e.g. robot_model.xml"); defineOptionalProperty<std::string>("RobotFileNameProject", "", "Project in which the robot filename is located (if robot is loaded from an external project)"); + defineOptionalProperty<std::string>("TopicPrefix", "", "Prefix for the sensor value topic name."); + } }; diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.cpp b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.cpp index 94c7b9d8481c0a58a0e9de33cadabdc828e53a75..3be94c7a50619cfe95ff85046d544afd032e9888 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.cpp +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.cpp @@ -41,6 +41,11 @@ namespace armarx return robotPlatformName; } + std::string RobotData::getRobotPlatformInstanceName() const + { + return robotPlatformInstanceName; + } + const std::string& RobotData::getRobotNodetSeName() const { throwIfInControlThread(BOOST_CURRENT_FUNCTION); @@ -82,6 +87,8 @@ namespace armarx return clone; } + + void RobotData::_initVirtualRobot() { throwIfInControlThread(BOOST_CURRENT_FUNCTION); @@ -94,6 +101,7 @@ namespace armarx robotProjectName = getProperty<std::string>("RobotFileNameProject").getValue(); robotFileName = getProperty<std::string>("RobotFileName").getValue(); robotPlatformName = getProperty<std::string>("PlatformName").getValue(); + robotPlatformInstanceName = getProperty<std::string>("PlatformInstanceName").getValue(); //load robot { diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.h b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.h index 0c0457b99f6b2242e82adefa656718ddcfb42c15..ff1e0637952cff7229a8ece8af322cfb205bd23f 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.h +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleRobotData.h @@ -55,7 +55,11 @@ namespace armarx "Robot node set name as defined in robot xml file, e.g. 'LeftArm'"); defineOptionalProperty<std::string>( "PlatformName", "Platform", - "Name of the platform (will publish values on PlatformName + 'State')"); + "Name of the platform needs to correspond to a node in the virtual robot."); + defineOptionalProperty<std::string>( + "PlatformInstanceName", "Platform", + "Name of the platform instance (will publish values on PlatformInstanceName + 'State')"); + } }; @@ -114,6 +118,12 @@ namespace armarx */ std::string getRobotName() const; + /** + * @brief Returns the name of the robot platform instance. Used for the platform topic: RobotPlatformInstance + "State" + */ + std::string getRobotPlatformInstanceName() const; + + /** * @brief Returns a clone of the robot's model * @return A clone of the robot's model @@ -122,6 +132,7 @@ namespace armarx // //////////////////////////////////////////////////////////////////////////////////////// // // ///////////////////////////////////////// Data ///////////////////////////////////////// // // //////////////////////////////////////////////////////////////////////////////////////// // + private: /// @brief The name of the robot's RobotNodeSet std::string robotNodeSetName; @@ -131,6 +142,8 @@ namespace armarx std::string robotFileName; /// @brief The name of the robot's platform std::string robotPlatformName; + /// @brief The name of the robot's platform instance + std::string robotPlatformInstanceName; /// @brief The robot's model. VirtualRobot::RobotPtr robot; diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.cpp b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.cpp index be11508013b7f3276c2b487476179136e9e557ba..59a461de68ca785b78ee4adfa95e43218b1a7a44 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.cpp +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.cpp @@ -266,6 +266,8 @@ namespace armarx properties->setProperty(confPre + "RobotNodeSetName", _module<RobotData>().getRobotNodetSeName()); properties->setProperty(confPre + "RobotFileName", _module<RobotData>().getRobotFileName()); properties->setProperty(confPre + "RobotFileNameProject", _module<RobotData>().getRobotProjectName()); + properties->setProperty(confPre + "TopicPrefix", getProperty<std::string>("KinematicUnitNameTopicPrefix")); + ARMARX_DEBUG << "creating unit " << configName << " using these properties: " << properties->getPropertiesForPrefix(""); IceInternal::Handle<UnitT> unit = Component::create<UnitT>(properties, configName, getConfigDomain()); @@ -317,7 +319,7 @@ namespace armarx Ice::PropertiesPtr properties = getIceProperties()->clone(); //properties->setProperty(confPre + "MinimumLoggingLevel", getProperty<std::string>("MinimumLoggingLevel").getValue()); //fill properties - properties->setProperty(confPre + "PlatformName", _module<RobotData>().getRobotPlatformName()); + properties->setProperty(confPre + "PlatformName", _module<RobotData>().getRobotPlatformInstanceName()); ARMARX_DEBUG << "creating unit " << configName << " using these properties: " << properties->getPropertiesForPrefix(""); IceInternal::Handle<UnitT> unit = Component::create<UnitT>(properties, configName, getConfigDomain()); //config diff --git a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.h b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.h index 7978f56c700d39eda754f675f8889e013afacc2d..54d6c2dcc75ad6b33f9f1a865676da86d2d9833c 100644 --- a/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.h +++ b/source/RobotAPI/components/units/RobotUnit/RobotUnitModules/RobotUnitModuleUnits.h @@ -39,6 +39,10 @@ namespace armarx defineOptionalProperty<std::string>( "KinematicUnitName", "KinematicUnit", "The name of the created kinematic unit"); + defineOptionalProperty<std::string>( + "KinematicUnitNameTopicPrefix", "", + "Prefix for the kinematic sensor values topic"); + defineOptionalProperty<std::string>( "PlatformUnitName", "PlatformUnit",