24#include <SimoxUtility/json/json.hpp>
25#include <VirtualRobot/Robot.h>
26#include <VirtualRobot/XML/RobotIO.h>
50 properties.oneShot,
"p.oneShot",
"If true, commit once after connecting, then stop.");
52 properties.updateFrequency,
"p.updateFrequency",
"Memory update frequency (write).");
54 defs->optional(properties.robot.name,
56 "Optional override for the robot name. If not set, the default name from "
57 "the robot model is used.");
59 properties.robot.package,
"p.robot.package",
"Package of the Simox robot XML.");
60 defs->optional(properties.robot.path,
"p.robot.path",
"Local path of the Simox robot XML.");
62 defs->optional(properties.robot.jointValues,
63 "p.robot.jointValues",
64 "Specify a certain joint configuration.");
66 defs->optional(properties.robot.globalPositionX,
"p.robot.globalPositionX",
"");
67 defs->optional(properties.robot.globalPositionY,
"p.robot.globalPositionY",
"");
68 defs->optional(properties.robot.globalPositionYaw,
"p.robot.globalPositionYaw",
"");
76 return "SimpleVirtualRobot";
103 SimpleVirtualRobot::loadRobot(
const Properties::Robot& p)
const
105 if (p.package.empty() or p.path.empty())
108 <<
"Please specify the Simox robot XMl file in the properties.";
116 path.toSystemPath(), VirtualRobot::RobotIO::eStructure);
120 if (not p.jointValues.empty())
124 const nlohmann::json j = nlohmann::json::parse(p.jointValues);
127 std::map<std::string, float> jointValues;
128 nlohmann::from_json(j, jointValues);
130 ARMARX_VERBOSE <<
"The following joint values are given by the user: " << jointValues;
131 robot->setJointValues(jointValues);
134 const Eigen::Isometry3f global_T_robot =
135 Eigen::Translation3f{
137 Eigen::AngleAxisf{properties.robot.globalPositionYaw, Eigen::Vector3f::UnitZ()};
138 robot->setGlobalPose(global_T_robot.matrix());
140 if (not p.name.empty())
142 robot->setName(p.name);
153 while (task and not task->isStopped())
155 if (robot ==
nullptr)
157 robot = loadRobot(properties.robot);
160 ARMARX_INFO <<
"Start to commit robot '" << robot->getName()
161 <<
"' to the robot state memory.";
173 bool success = virtualRobotWriterPlugin->get().storeDescription(*robot, now);
176 success = virtualRobotWriterPlugin->get().storeState(*robot, now);
181 if (properties.oneShot)
Default component property definition container.
std::string getConfigIdentifier()
Retrieve config identifier for this component as set in constructor.
static Frequency HertzDouble(double hertz)
PluginT * addPlugin(const std::string prefix="", ParamsT &&... params)
Simple rate limiter for use in loops to maintain a certain frequency given a clock.
Duration waitForNextTick() const
Wait and block until the target period is met.
void onInitComponent() override
Pure virtual hook for the subclass.
void onDisconnectComponent() override
Hook for subclass.
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override
void onConnectComponent() override
Pure virtual hook for the subclass.
void onExitComponent() override
Hook for subclass.
std::string getDefaultName() const override
Retrieve default name of component.
#define ARMARX_CHECK(expression)
Shortcut for ARMARX_CHECK_EXPRESSION.
#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...
#define ARMARX_INFO
The normal logging level.
#define ARMARX_IMPORTANT
The logging level for always important information, but expected behaviour (in contrast to ARMARX_WAR...
#define ARMARX_DEBUG
The logging level for output that is only interesting while debugging.
#define ARMARX_VERBOSE
The logging level for verbose information.
std::shared_ptr< class Robot > RobotPtr
armarx::core::time::DateTime Time
IceUtil::Handle< class PropertyDefinitionContainer > PropertyDefinitionsPtr
PropertyDefinitions smart pointer type.
SimpleRunningTask(Ts...) -> SimpleRunningTask< std::function< void(void)> >