Go to the documentation of this file.
25 #include <SimoxUtility/algorithm/string/string_tools.h>
26 #include <VirtualRobot/Nodes/RobotNode.h>
27 #include <VirtualRobot/RobotNodeSet.h>
28 #include <VirtualRobot/VirtualRobot.h>
29 #include <VirtualRobot/XML/RobotIO.h>
52 robotNodeSetName = getProperty<std::string>(
"RobotNodeSetName").getValue();
63 usingTopic(getProperty<std::string>(
"TopicPrefix").getValue() + robotNodeSetName +
"State");
71 std::string robotFile = getProperty<std::string>(
"RobotFileName").getValue();
72 std::string
project = getProperty<std::string>(
"RobotFileNameProject").getValue();
73 Ice::StringSeq includePaths;
82 includePaths.end(), projectIncludePaths.begin(), projectIncludePaths.end());
87 throw UserException(
"Could not find robot file " + robotFile);
91 VirtualRobot::RobotIO::loadRobot(robotFile, VirtualRobot::RobotIO::eStructure);
93 if (robotNodeSetName ==
"")
95 throw UserException(
"RobotNodeSet not defined");
98 auto robotNodeSetPtr = robot->getRobotNodeSet(robotNodeSetName);
100 std::vector<VirtualRobot::RobotNodePtr> robotNodes;
101 robotNodes = robotNodeSetPtr->getAllRobotNodes();
102 auto robotNodeNames = robotNodeSetPtr->getNodeNames();
103 this->robotNodes = std::set<std::string>(robotNodeNames.begin(), robotNodeNames.end());
105 offerChannel(
"jointangles",
"Joint values of the " + robotNodeSetName +
" kinematic chain");
107 "Joint velocities of the " + robotNodeSetName +
" kinematic chain");
109 "Joint accelerations of the " + robotNodeSetName +
" kinematic chain");
111 "Joint torques of the" + robotNodeSetName +
" kinematic chain");
113 "Joint currents of the " + robotNodeSetName +
" kinematic chain");
115 "Joint motor temperatures of the " + robotNodeSetName +
" kinematic chain");
117 "Joint motor temperatures of the " + robotNodeSetName +
" kinematic chain");
121 for (std::vector<VirtualRobot::RobotNodePtr>::iterator it = robotNodes.begin();
122 it != robotNodes.end();
125 std::string jointName = (*it)->getName();
130 "Controlmode of the " + jointName +
" joint");
134 "Joint angle of the " + jointName +
" joint in radians");
138 "Joint velocity of the " + jointName +
" joint");
142 "Joint acceleration of the " + jointName +
" joint");
146 "Joint torque of the " + jointName +
" joint");
150 "Joint current of the " + jointName +
" joint");
154 "Joint motor temperature of the " + jointName +
" joint");
167 const Ice::Current&
c)
171 if (jointModes.size() == 0)
176 for (
auto elem : jointModes)
194 const Ice::Current&
c)
220 const Ice::Current&
c)
244 const Ice::Current&
c)
268 const Ice::Current&
c)
272 if (jointAccelerations.size() == 0)
279 "jointaccelerations", jointAccelerations,
timestamp, aValueChanged);
293 const Ice::Current&
c)
317 const Ice::Current&
c)
321 if (jointMotorTemperatures.size() == 0)
328 "jointmotortemperatures", jointMotorTemperatures,
timestamp, aValueChanged);
342 const Ice::Current&
c)
362 if (aValueChanged || newChannel)
365 std::unordered_map<::std::string, ::armarx::VariantBasePtr> map;
368 for (
const auto& it : nameValueMap)
370 if (robotNodes.count(it.first))
372 map[it.first] =
new Variant(it.second);
378 for (
const auto& it : nameValueMap)
380 if (robotNodes.count(it.first))
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.