8 #include <SimoxUtility/math/convert/mat4f_to_pos.h>
9 #include <SimoxUtility/math/convert/mat4f_to_rpy.h>
14 #include <ArmarXCore/interface/serialization/Eigen/Eigen_fdi.h>
23 #include <armarx/navigation/trajectory_control/global/aron/TrajectoryFollowingControllerParams.aron.generated.h>
40 arondto::TrajectoryFollowingControllerParams dto;
51 arondto::TrajectoryFollowingControllerParams dto;
64 pidPos(params.pidPos.Kp,
67 std::numeric_limits<double>::
max(),
68 std::numeric_limits<double>::
max(),
70 std::vector<bool>{
false,
false,
false}),
71 pidPosTarget(params.pidPos.Kp,
77 std::vector<bool>{
false,
false,
false}),
78 pidOri(params.pidOri.Kp,
84 std::vector<bool>{
true,
true,
true}),
85 pidOriTarget(params.pidOri.Kp,
91 std::vector<bool>{
true,
true,
true})
94 <<
VAROUT(params.limits.linear) <<
", " <<
VAROUT(params.limits.angular);
103 .angular = Eigen::Vector3f::Zero()};
116 const float scalePos = twist.
linear.norm() / limits.linear.norm();
117 const auto scaleOri = twist.
angular.cwiseAbs().cwiseQuotient(limits.angular.cwiseAbs());
122 const float scaleMax =
std::max(scalePos, scaleOri.maxCoeff());
165 <<
"Scaling factor for velocity may not be negative, but is " << velocityFactor;
167 <<
"Scaling factor for velocity may not be > 1, but is " << velocityFactor;
176 using simox::math::mat4f_to_pos;
177 using simox::math::mat4f_to_rpy;
180 const float currentOrientation = mat4f_to_rpy(currentPose.matrix()).z();
182 if (trajectory.
points().empty())
188 .isFinalSegment =
true,
189 .currentOrientation = currentOrientation,
190 .desiredOrientation = currentOrientation,
191 .orientationError = 0,
200 pidPos.
update(mat4f_to_pos(currentPose.matrix()),
201 mat4f_to_pos(projectedPose.projection.waypoint.pose.matrix()));
202 pidOri.
update(mat4f_to_rpy(currentPose.matrix()),
203 mat4f_to_rpy(projectedPose.projection.waypoint.pose.matrix()));
205 const float desiredOrientation =
206 mat4f_to_rpy(projectedPose.projection.waypoint.pose.matrix()).z();
219 pidPosTarget.
update(currentPose.translation(),
220 trajectory.
points().back().waypoint.pose.translation());
223 mat4f_to_rpy(currentPose.matrix()),
224 mat4f_to_rpy(trajectory.
points().back().waypoint.pose.matrix()));
232 pidPosTarget.
reset();
235 const Eigen::Vector3f desiredMovementDirection =
236 (projectedPose.wayPointAfter.waypoint.pose.translation() -
237 projectedPose.wayPointBefore.waypoint.pose.translation())
240 const float ffVel = projectedPose.projection.velocity;
244 const auto feedforwardVelocity = desiredMovementDirection * ffVel;
247 << feedforwardVelocity.normalized();
264 const auto& twistGlobal = twistScaled;
267 twistLocal.
linear = global_T_robot.linear().inverse() * twistGlobal.linear;
269 twistLocal.
angular = twistGlobal.angular;
276 .dropPoint = projectedPose.projection,
277 .isFinalSegment = isFinalSegment,
278 .currentOrientation = currentOrientation,
279 .desiredOrientation = desiredOrientation,
280 .orientationError =
std::abs(currentOrientation - desiredOrientation),
281 .positionError = (global_T_robot.translation() -
282 trajectory.
points().back().waypoint.pose.translation())