28 #include <VirtualRobot/VirtualRobot.h>
42 #include <armarx/control/interface/ConfigurableNJointControllerInterface.h>
44 #include <armarx/control/njoint_controller/joint_space/aron/WholeBodyTrajectoryControllerConfig.aron.generated.h>
48 class ControlTargetHolonomicPlatformVelocity;
49 class SensorValueHolonomicPlatformWithAbsolutePosition;
61 using TrajectoryPoint = armarx::control::njoint_controller::joint_space::
62 whole_body_trajectory_controller::arondto::TrajectoryPoint;
66 Trajectory(
const std::vector<TrajectoryPoint>& traj) : trajectory_(traj)
73 return trajectory_.front();
79 startTimestampUS_ = timestamp;
90 return timestamp >=
min and timestamp <=
max;
94 std::optional<TrajectoryPoint>
104 return trajectory_.front();
109 return trajectory_.back();
117 const TimestampUS relativeTimeUS = timestamp - startTimestampUS_.value();
124 {
return lhs.timestampMicroSeconds < val; };
127 std::lower_bound(trajectory_.begin(), trajectory_.end(), relativeTimeUS, compareFn);
130 if (it == trajectory_.begin())
135 const auto itBefore = std::prev(it);
138 const double f =
static_cast<double>(relativeTimeUS - itBefore->timestampMicroSeconds) /
139 (it->timestampMicroSeconds - itBefore->timestampMicroSeconds);
142 const auto linearInterpolate = [](
const std::vector<double>&
a,
143 const std::vector<double>& b,
144 const double f) -> std::vector<double>
151 const std::size_t n =
a.size();
153 std::vector<double>
c(n);
155 for (std::size_t i = 0; i < n; i++)
157 c.at(i) = (1 - f) *
a.at(i) + f * b.at(i);
169 tp.timestampMicroSeconds = timestamp;
170 tp.jointValues = linearInterpolate(itBefore->jointValues, it->jointValues, f);
171 tp.jointValuesPlatform =
172 linearInterpolate(itBefore->jointValuesPlatform, it->jointValuesPlatform, f);
174 linearInterpolate(itBefore->handJointValues, it->handJointValues, f);
177 linearInterpolate(itBefore->jointVelocities, it->jointVelocities, f);
178 tp.jointVelocitiesPlatform = linearInterpolate(
179 itBefore->jointVelocitiesPlatform, it->jointVelocitiesPlatform, f);
198 return {.min = trajectory_.front().timestampMicroSeconds + startTimestampUS_.value(),
199 .max = trajectory_.back().timestampMicroSeconds + startTimestampUS_.value()};
204 const std::vector<armarx::control::njoint_controller::joint_space::
205 whole_body_trajectory_controller::arondto::TrajectoryPoint>
208 std::optional<std::int64_t> startTimestampUS_;
234 const NJointControllerConfigPtr& config,
238 std::string
getClassName(
const Ice::Current& iceCurrent = Ice::emptyCurrent)
const override;
261 struct ControlTargets
264 std::vector<ControlTarget1DoFActuatorVelocity*> jointTargets;
265 std::vector<ControlTarget1DoFActuatorPosition*> handTargets;
269 std::vector<const SensorValue1DoFActuatorPosition*> jointSensorValues_;
272 std::optional<Trajectory> trajectory_;
279 std::optional<MultiDimPIDController> pidArm_;
281 std::vector<std::string> jointNames_;
282 std::vector<std::string> fingerJointNames_;
285 VirtualRobot::RobotNodePtr rtTcpNode_;
288 VirtualRobot::RobotNodePtr publishTcpNode_;
294 std::vector<DebugData> whatever_;
295 std::atomic_bool whateverFlag_ =
true;