Go to the documentation of this file.
35 #include <VirtualRobot/VirtualRobot.h>
36 #include <VirtualRobot/XML/RobotIO.h>
37 #include <VirtualRobot/RobotNodeSet.h>
38 #include <VirtualRobot/Nodes/RobotNode.h>
41 #include <SimoxUtility/algorithm/string/string_tools.h>
50 robotNodeSetName = getProperty<std::string>(
"RobotNodeSetName").getValue();
61 usingTopic(getProperty<std::string>(
"TopicPrefix").getValue() + robotNodeSetName +
"State");
68 std::string robotFile = getProperty<std::string>(
"RobotFileName").getValue();
69 std::string
project = getProperty<std::string>(
"RobotFileNameProject").getValue();
70 Ice::StringSeq includePaths;
78 includePaths.insert(includePaths.end(), projectIncludePaths.begin(), projectIncludePaths.end());
83 throw UserException(
"Could not find robot file " + robotFile);
86 VirtualRobot::RobotPtr robot = VirtualRobot::RobotIO::loadRobot(robotFile, VirtualRobot::RobotIO::eStructure);
88 if (robotNodeSetName ==
"")
90 throw UserException(
"RobotNodeSet not defined");
93 auto robotNodeSetPtr = robot->getRobotNodeSet(robotNodeSetName);
95 std::vector< VirtualRobot::RobotNodePtr > robotNodes;
96 robotNodes = robotNodeSetPtr->getAllRobotNodes();
97 auto robotNodeNames = robotNodeSetPtr->getNodeNames();
98 this->robotNodes = std::set<std::string>(robotNodeNames.begin(), robotNodeNames.end());
100 offerChannel(
"jointangles",
"Joint values of the " + robotNodeSetName +
" kinematic chain");
101 offerChannel(
"jointvelocities",
"Joint velocities of the " + robotNodeSetName +
" kinematic chain");
102 offerChannel(
"jointaccelerations",
"Joint accelerations of the " + robotNodeSetName +
" kinematic chain");
103 offerChannel(
"jointtorques",
"Joint torques of the" + robotNodeSetName +
" kinematic chain");
104 offerChannel(
"jointcurrents",
"Joint currents of the " + robotNodeSetName +
" kinematic chain");
105 offerChannel(
"jointmotortemperatures",
"Joint motor temperatures of the " + robotNodeSetName +
" kinematic chain");
106 offerChannel(
"jointcontrolmodes",
"Joint motor temperatures of the " + robotNodeSetName +
" kinematic chain");
110 for (std::vector<VirtualRobot::RobotNodePtr>::iterator it = robotNodes.begin(); it != robotNodes.end(); it++)
112 std::string jointName = (*it)->getName();
135 if (jointModes.size() == 0)
140 for (
auto elem : jointModes)
221 if (jointAccelerations.size() == 0)
261 if (jointMotorTemperatures.size() == 0)
293 if (aValueChanged || newChannel)
296 std::unordered_map< ::std::string, ::armarx::VariantBasePtr> map;
299 for (
const auto& it : nameValueMap)
301 if (robotNodes.count(it.first))
303 map[it.first] =
new Variant(it.second);
309 for (
const auto& it : nameValueMap)
311 if (robotNodes.count(it.first))
313 map[it.first] =
new TimedVariant(
new Variant(it.second), IceUtil::Time::microSeconds(timestamp));
void updateChannel(const std::string &channelName, const std::set< std::string > &updatedDatafields=std::set< std::string >())
Update all conditions for a channel.
void reportControlModeChanged(const NameControlModeMap &jointModes, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
The Variant class is described here: Variants.
const VariantTypeId Float
void reportJointMotorTemperatures(const NameValueMap &jointMotorTemperatures, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
void onInitObserver() override
Framework hook.
The CMakePackageFinder class provides an interface to the CMake Package finder capabilities.
void setDataFieldsFlatCopy(const std::string &channelName, const StringVariantBaseMap &datafieldValues, bool triggerFilterUpdate=true)
void updateDatafieldTimestamps(const std::string &channelName, const std::unordered_map< std::string, Ice::Long > &datafieldValues)
void reportJointStatuses(const NameStatusMap &jointStatuses, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
void onConnectObserver() override
Framework hook.
static std::string ControlModeToString(ControlMode mode)
void setDataFieldFlatCopy(const std::string &channelName, const std::string &datafieldName, const VariantPtr &value, bool triggerFilterUpdate=true)
std::string getDataDir() const
const KinematicUnitDatafieldCreator jointVelocities("jointVelocities")
void nameValueMapToDataFields(const std::string &channelName, const NameValueMap &nameValueMap, Ice::Long timestamp, bool aValueChanged)
void reportJointAccelerations(const NameValueMap &jointAccelerations, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c) override
std::mutex initializedChannelsMutex
const KinematicUnitDatafieldCreator jointAngles("jointAngles")
void usingTopic(const std::string &name, bool orderedPublishing=false)
Registers a proxy for subscription after initialization.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
const KinematicUnitDatafieldCreator jointCurrents("jointCurrents")
void reportJointCurrents(const NameValueMap &jointCurrents, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
PropertyDefinitionsPtr createPropertyDefinitions() override
void offerConditionCheck(std::string checkName, ConditionCheck *conditionCheck)
Offer a condition check.
static bool getAbsolutePath(const std::string &relativeFilename, std::string &storeAbsoluteFilename, const std::vector< std::string > &additionalSearchPaths={}, bool verbose=true)
void offerDataFieldWithDefault(std::string channelName, std::string datafieldName, const Variant &defaultValue, std::string description)
Offer a datafield with default value.
const KinematicUnitDatafieldCreator jointTorques("jointTorques")
void reportJointVelocities(const NameValueMap &jointVelocities, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
void reportJointTorques(const NameValueMap &jointTorques, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
void offerDataField(std::string channelName, std::string datafieldName, VariantTypeId type, std::string description)
Offer a datafield without default value.
This file offers overloads of toIce() and fromIce() functions for STL container types.
void reportJointAngles(const NameValueMap &jointAngles, Ice::Long timestamp, bool aValueChanged, const Ice::Current &c=Ice::emptyCurrent) override
std::shared_ptr< class Robot > RobotPtr
std::set< std::string > initializedChannels
std::vector< std::string > split(const std::string &source, const std::string &splitBy, bool trimElements=false, bool removeEmptyElements=false)
void offerChannel(std::string channelName, std::string description)
Offer a channel.