28#include <SimoxUtility/math/convert/mat3f_to_rpy.h>
29#include <SimoxUtility/math/convert/mat4f_to_rpy.h>
30#include <SimoxUtility/math/periodic/periodic_clamp.h>
31#include <VirtualRobot/Robot.h>
42 "NJointHolonomicPlatformGlobalPositionController");
47 const NJointHolonomicPlatformGlobalPositionControllerConfigPtr& cfg,
49 pid(cfg->p, cfg->i, cfg->d, cfg->maxVelocity, cfg->maxAcceleration),
53 cfg->maxRotationVelocity,
54 cfg->maxRotationAcceleration,
65 pid.threadSafe =
false;
68 opid.threadSafe =
false;
73 const IceUtil::Time& currentTime,
74 const IceUtil::Time& timeSinceLastIteration)
76 const auto global_T_robot =
sv->global_T_root;
78 const Eigen::Vector3f rpy = simox::math::mat4f_to_rpy(global_T_robot);
79 const float global_orientation = rpy.z();
80 const Eigen::Vector2f global_P_robot = global_T_robot.block<2, 1>(0, 3);
111 target->velocityRotation = 0;
116 if (not
sv->isAvailable())
121 target->velocityRotation = 0;
126 const float measuredOrientation = global_orientation;
130 opid.update(timeSinceLastIteration.toSecondsDouble(),
131 static_cast<double>(measuredOrientation),
134 const Eigen::Rotation2Df global_R_local(-measuredOrientation);
135 const Eigen::Vector2f velocities = global_R_local *
pid.getControlValue();
137 target->velocityX = velocities.x();
138 target->velocityY = velocities.y();
139 target->velocityRotation =
static_cast<float>(
opid.getControlValue());
147 target->velocityRotation = 0;
154 float translationAccuracy,
155 float rotationAccuracy)
163 simox::math::periodic_clamp(
static_cast<double>(yaw), -
M_PI,
M_PI);
static std::string DeviceName()
SensorValueGlobalRobotPose SensorValueType
const SensorValueBase * useSensorValue(const std::string &sensorDeviceName) const
Get a const ptr to the given SensorDevice's SensorValue.
ControlTargetBase * useControlTarget(const std::string &deviceName, const std::string &controlMode)
Declares to calculate the ControlTarget for the given ControlDevice in the given ControlMode when rtR...
const NJointHolonomicPlatformGlobalPositionControllerTarget & rtGetControlStruct() const
MutexType controlDataMutex
void writeControlStruct()
NJointHolonomicPlatformGlobalPositionControllerTarget & getWriterControlStruct()
The RobotUnit class manages a robot and its controllers.
The SensorValueBase class.
std::shared_ptr< class Robot > RobotPtr
This file offers overloads of toIce() and fromIce() functions for STL container types.
NJointControllerRegistration< NJointHolonomicPlatformGlobalPositionController > registrationNJointHolonomicPlatformGlobalPositionController("NJointHolonomicPlatformGlobalPositionController")