24#include <SimoxUtility/json/json.hpp>
25#include <VirtualRobot/Robot.h>
26#include <VirtualRobot/XML/RobotIO.h>
36 "SimpleVirtualRobot");
54 properties.oneShot,
"p.oneShot",
"If true, commit once after connecting, then stop.");
56 properties.updateFrequency,
"p.updateFrequency",
"Memory update frequency (write).");
58 defs->optional(properties.robot.name,
60 "Optional override for the robot name. If not set, the default name from "
61 "the robot model is used.");
63 properties.robot.package,
"p.robot.package",
"Package of the Simox robot XML.");
64 defs->optional(properties.robot.path,
"p.robot.path",
"Local path of the Simox robot XML.");
66 defs->optional(properties.robot.jointValues,
67 "p.robot.jointValues",
68 "Specify a certain joint configuration.");
70 defs->optional(properties.robot.globalPositionX,
"p.robot.globalPositionX",
"");
71 defs->optional(properties.robot.globalPositionY,
"p.robot.globalPositionY",
"");
72 defs->optional(properties.robot.globalPositionYaw,
"p.robot.globalPositionYaw",
"");
80 return "SimpleVirtualRobot";
107 SimpleVirtualRobot::loadRobot(
const Properties::Robot& p)
const
109 if (p.package.empty() or p.path.empty())
112 <<
"Please specify the Simox robot XMl file in the properties.";
120 path.toSystemPath(), VirtualRobot::RobotIO::eStructure);
124 if (not p.jointValues.empty())
128 const nlohmann::json j = nlohmann::json::parse(p.jointValues);
131 std::map<std::string, float> jointValues;
132 nlohmann::from_json(j, jointValues);
134 ARMARX_VERBOSE <<
"The following joint values are given by the user: " << jointValues;
135 robot->setJointValues(jointValues);
138 const Eigen::Isometry3f global_T_robot =
139 Eigen::Translation3f{
141 Eigen::AngleAxisf{properties.robot.globalPositionYaw, Eigen::Vector3f::UnitZ()};
142 robot->setGlobalPose(global_T_robot.matrix());
144 if (not p.name.empty())
146 robot->setName(p.name);
157 while (task and not task->isStopped())
159 if (robot ==
nullptr)
161 robot = loadRobot(properties.robot);
164 ARMARX_INFO <<
"Start to commit robot '" << robot->getName()
165 <<
"' to the robot state memory.";
177 bool success = virtualRobotWriterPlugin->get().storeDescription(*robot, now);
180 success = virtualRobotWriterPlugin->get().storeState(*robot, now);
185 if (properties.oneShot)
#define ARMARX_REGISTER_COMPONENT_EXECUTABLE(ComponentT, applicationName)
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.
Brief description of class SimpleVirtualRobot.
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)> >