7#include <SimoxUtility/math/convert/deg_to_rad.h>
8#include <VirtualRobot/VirtualRobot.h>
16#include <RobotAPI/libraries/aron/common/aron/framed.aron.generated.h>
21#include <armarx/navigation/skills/aron/MoveRelativePlanar.aron.generated.h>
22#include <armarx/navigation/skills/aron/NavigatingSkillParams.aron.generated.h>
28 armarx::skills::SkillDescription
32 defaultParams.translationCartesian = std::nullopt;
33 defaultParams.translationPolar = std::nullopt;
34 defaultParams.rotationRadians = std::nullopt;
35 defaultParams.rotationDegrees = std::nullopt;
37 defaultParams.navigatingSkillParams.globalPlanningAlgorithm =
38 arondto::GlobalPlanningAlgorithm::Point2Point;
39 defaultParams.navigatingSkillParams.p2pCheckCollisionsAlongTrajectory =
false;
41 static const std::string nl =
"\n\n";
43 std::stringstream desc;
44 desc <<
"**Move the robot relatively to its current pose in the horizontal plane.**";
47 <<
"The parameters `translationCartesian` and `translationPolar` specify the "
48 "translation of the robot. (If both are given, `translationCartesian` takes "
49 "precedence over `translationPolar`.)";
52 <<
"`translationCartesian` specifies the relative translation in Cartesian"
53 " coordinates (x, y). The corresponding coordinate system is specified by its "
54 "`frameID`. If `frameID` is not given, the robot's root coordinate system is used."
55 "To define a translation in the global frame, set `frame` to `Global` (and leave "
59 <<
"`translationPolar` specifies the relative translation in polar coordinates"
60 " (direction, distance), where"
61 << nl <<
"- `direction = 0` moves the robot forward," << nl
62 <<
"- `direction > 0` moves the robot to the left," << nl
63 <<
"- `direction < 0` moves the robot to the right." << nl
64 <<
" (Generally, `forward` is defined as the +y axis of the robot root frame.)";
67 <<
"`rotationRadians` and `rotationDegrees` specify the rotation around the +z axis"
70 <<
"(If both are given, `rotationRadians` takes precedence over `rotationDegrees`.)"
71 << nl <<
"- `directionDegrees = 0` does not turn the robot," << nl
72 <<
"- `directionDegrees > 0` turns the robot to the left," << nl
73 <<
"- `directionDegrees < 0` turns the robot to the right.";
77 .description = desc.str(),
78 .rootProfileDefaults = defaultParams.toAron(),
80 .parametersType = ParamType::ToAronType(),
89 properties{properties},
98 makeTranslation(
const arondto::FramedCartesian2D& cartesian,
100 const std::string& defaultRobotName)
102 Eigen::Vector3f translation;
103 translation << cartesian.translationCartesian.cast<
float>(), 0;
106 if (cartesian.frameID.has_value())
108 armarx::arondto::FrameID frameID = cartesian.frameID.value();
110 if (frameID.agent.empty())
113 frameID.agent = defaultRobotName;
118 <<
"Robot " <<
QUOTED(frameID.agent) <<
" not found in robot reader";
121 <<
"Failed to synchronize robot " <<
QUOTED(frameID.agent);
123 if (frameID.frame.empty())
125 frameID.frame = robot->getRootNode()->getName();
130 return dir.toRootFrame(robot)->toEigen();
140 makeTranslation(
const arondto::Polar& polar,
141 const Eigen::Vector3f forward,
142 const Eigen::Vector3f up)
144 const Eigen::AngleAxisf rotation(simox::math::deg_to_rad(polar.directionDegrees), up);
145 const Eigen::Vector3f translation = polar.distanceMillimeters * (rotation * forward);
151 makeRotation(
float rotationRadians,
const Eigen::Vector3f up)
153 return Eigen::AngleAxisf(rotationRadians, up);
158 MoveRelativePlanar::relativeTarget(
const Base::SpecializedMainInput& in)
161 static const Eigen::Vector3f forward = Eigen::Vector3f::UnitY();
162 static const Eigen::Vector3f
up = Eigen::Vector3f::UnitZ();
166 Eigen::Isometry3f relativeTarget = Eigen::Isometry3f::Identity();
169 if (
parameters.translationCartesian.has_value())
171 relativeTarget.translation() = makeTranslation(
parameters.translationCartesian.value(),
172 services.robotReader,
173 properties.robotName);
175 else if (
parameters.translationPolar.has_value())
177 relativeTarget.translation() =
178 makeTranslation(
parameters.translationPolar.value(), forward, up);
182 std::optional<float> rotationRadians =
parameters.rotationRadians;
183 if (not rotationRadians.has_value() and
parameters.rotationDegrees.has_value())
185 rotationRadians = simox::math::deg_to_rad(
parameters.rotationDegrees.value());
187 if (rotationRadians.has_value())
189 relativeTarget.linear() =
190 relativeTarget.linear() * makeRotation(rotationRadians.value(), up);
193 return relativeTarget;
static DateTime Now()
Current time on the virtual clock.
FramedDirection is a 3 dimensional direction vector with a reference frame.
The VirtualRobotReader class.
VirtualRobot::RobotPtr getRobot(const std::string &name, const armem::Time ×tamp=armem::Time::Invalid(), const VirtualRobot::RobotIO::RobotDescription &loadMode=VirtualRobot::RobotIO::RobotDescription::eStructure)
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...
static Duration Minutes(std::int64_t minutes)
Constructs a duration in minutes.
MoveRelativePlanar(const NavigatingSkillHelper::Properties &baseProperties, const NavigatingSkillHelper::Services &baseSrv, const Properties &properties, const Services &srv)
static armarx::skills::SkillDescription DefaultSkillDescription()
NavigateRelativeSkill< arondto::MoveRelativePlanarParams > Base
static arondto::NavigatingSkillParams DefaultSkillDescription()
armarx::aron::data::DictPtr parameters
#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...
std::shared_ptr< class Robot > RobotPtr
const std::string MoveRelativePlanar
state::Type up(state::Type previous)