Go to the documentation of this file.
8 #include <VirtualRobot/Robot.h>
9 #include <VirtualRobot/VirtualRobot.h>
10 #include <VirtualRobot/XML/BaseIO.h>
11 #include <VirtualRobot/XML/RobotIO.h>
33 << robot.getName() <<
"` " <<
"(type `" << robot.getType() <<
"`)!";
37 robot.setJointValues(robotState->jointMap);
38 robot.setGlobalPose(robotState->globalPose.matrix());
51 << robot.getName() <<
"` " <<
"(type `" << robot.getType() <<
"`)!";
55 robot.setJointValues(robotState->jointMap);
65 const auto robotState = queryState(robot.getName(),
timestamp);
69 << robot.getName() <<
"` " <<
"(type `" << robot.getType() <<
"`)!";
73 robot.setGlobalPose(robotState->globalPose.matrix());
81 const VirtualRobot::RobotIO::RobotDescription& loadMode)
90 <<
"` is not a available!";
95 const std::string xmlFilename = description->xml.toSystemPath();
96 ARMARX_CHECK(std::filesystem::exists(xmlFilename)) << xmlFilename;
99 <<
"' from XML file '" << xmlFilename <<
"'";
101 auto robot = VirtualRobot::RobotIO::loadRobot(xmlFilename, loadMode);
104 robot->setName(name);
112 const VirtualRobot::RobotIO::RobotDescription& loadMode)
114 ARMARX_INFO <<
"Trying to get robot `" << name <<
"` ...";
123 if (robot ==
nullptr)
126 <<
"`. At the moment, a blocking behavior is not possible in "
127 "onConnectComponent()."
128 <<
"Therefore, a nullptr will be returned. This will likely cause "
129 "problems downstream.";
145 const VirtualRobot::BaseIO::RobotDescription& loadMode,
153 const std::string& name,
155 const VirtualRobot::RobotIO::RobotDescription& loadMode,
158 return _getSynchronizedRobot(name,
timestamp, loadMode, blocking);
162 VirtualRobotReader::_getSynchronizedRobot(
163 const std::string& name,
165 const VirtualRobot::BaseIO::RobotDescription& loadMode,
175 robot =
getRobot(name, ts, loadMode);
194 if (robot ==
nullptr)
std::optional< RobotState > queryJointState(const std::string &robotName, const armem::Time ×tamp) const
VirtualRobot::RobotPtr getRobot(const std::string &name, const armem::Time ×tamp=armem::Time::Invalid(), const VirtualRobot::RobotIO::RobotDescription &loadMode=VirtualRobot::RobotIO::RobotDescription::eStructure)
static void WaitFor(const Duration &duration)
Wait for a certain duration on the virtual clock.
#define ARMARX_CHECK_NOT_NULL(ptr)
This macro evaluates whether ptr is not null and if it turns out to be false it will throw an Express...
bool synchronizeRobot(VirtualRobot::Robot &robot, const armem::Time ×tamp) const
Synchronize both the platform pose and the joint values of a virtual robot, according to the robot st...
bool synchronizeRobotPose(VirtualRobot::Robot &robot, const armem::Time ×tamp) const
Synchronize only the platform pose of a virtual robot, according to the robot state memory for a cert...
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
SpamFilterDataPtr deactivateSpam(SpamFilterDataPtr const &spamFilter, float deactivationDurationSec, const std::string &identifier, bool deactivate)
VirtualRobot::RobotPtr getRobotWaiting(const std::string &name, const armem::Time ×tamp=armem::Time::Invalid(), const VirtualRobot::RobotIO::RobotDescription &loadMode=VirtualRobot::RobotIO::RobotDescription::eStructure)
In contrast to getRobot(), this function will retry to query the robot until it exists.
bool synchronizeRobotJoints(VirtualRobot::Robot &robot, const armem::Time ×tamp) const
Synchronize only the joint values of a virtual robot, according to the robot state memory for a certa...
std::optional< description::RobotDescription > queryDescription(const std::string &name, const armem::Time ×tamp) const
VirtualRobot::RobotPtr getSynchronizedRobot(const std::string &name, const VirtualRobot::RobotIO::RobotDescription &loadMode=VirtualRobot::RobotIO::RobotDescription::eStructure, bool blocking=true)
Represents a point in time.
static DateTime Now()
Current time on the virtual clock.
std::optional< RobotState > queryState(const std::string &robotName, const armem::Time ×tamp) const
armem::Duration sleepAfterFailure
static DateTime Invalid()
std::shared_ptr< class Robot > RobotPtr