26 #include <ArmarXCore/interface/core/BasicVectorTypesHelpers.h>
40 usingProxy(getProperty<std::string>(
"RobotStateComponentName").getValue());
41 usingProxy(getProperty<std::string>(
"KinematicUnitName").getValue());
42 usingProxy(getProperty<std::string>(
"KinematicUnitObserverName").getValue());
43 if (!getProperty<std::string>(
"RemoteGuiName").getValue().
empty())
45 usingProxy(getProperty<std::string>(
"RemoteGuiName").getValue());
49 frameName = getProperty<std::string>(
"FrameOnStartup").getValue();
62 getProperty<std::string>(
"RobotStateComponentName").getValue());
64 getProperty<std::string>(
"KinematicUnitName").getValue());
66 getProperty<std::string>(
"KinematicUnitObserverName").getValue());
72 ARMARX_ERROR << getProperty<std::string>(
"HeadYawJoint").getValue() <<
" is not a valid joint.";
78 ARMARX_ERROR << getProperty<std::string>(
"HeadPitchJoint").getValue() <<
" is not a valid joint.";
84 ARMARX_ERROR << getProperty<std::string>(
"CameraNode").getValue() <<
" is not a valid node.";
89 _enableTracking(getProperty<bool>(
"EnableTrackingOnStartup").getValue());
91 if (!getProperty<std::string>(
"RemoteGuiName").getValue().
empty())
93 _remoteGui = getProxy<RemoteGuiInterfacePrx>(getProperty<std::string>(
"RemoteGuiName").getValue());
113 2 * 1000000000 / 10).
value(0.f)).addChild(
115 2 * 1000000000 / 10).
value(0.f)).addChild(
117 2 * 1000000000 / 10).
value(0.f)).addChild(
123 2 * 1000000000 / 10).
value(0.f)).addChild(
125 2 * 1000000000 / 10).
value(0.f)).addChild(
127 2 * 1000000000 / 10).
value(0.f)).addChild(
149 static_cast<int>(6 / 0.1)).
value(0.8f)).addChild(
156 1000000000).steps(2 * 1000000000 / 10).
value(0.f)).addChild(
158 1000000000).steps(2 * 1000000000 / 10).
value(0.f)).addChild(
160 1000000000).steps(2 * 1000000000 / 10).
value(0.f)).addChild(
163 1000000000).steps(2 * 1000000000 / 10).
value(0.f)).addChild(
165 1000000000).steps(2 * 1000000000 / 10).
value(0.f)).addChild(
167 1000000000).steps(2 * 1000000000 / 10).
value(0.f)).addChild(
170 static_cast<int>(6 / 0.1)).
value(0.8f)).addChild(
173 static_cast<int>(8 / 0.1)).
value(4.0f)).addChild(
176 rootLayoutBuilder.
addChild(
new RemoteGui::VSpacer());
182 "tracking_frame").get();
193 if (oldFrameGui ==
frameName && oldFrameGui !=
195 "tracking_frame").get())
223 "robot_point_z").get()});
227 "button_scan_in_configuration_space").
clicked())
230 "scan_in_configuration_space_yaw_from").get(),
232 "scan_in_configuration_space_yaw_to").get(),
233 {_guiTab.getValue<float>(
234 "scan_in_configuration_space_pitch").get()},
236 "scan_in_configuration_space_velocity").get());
245 float>(
"scan_in_workspace_from_z").get()},
251 "scan_in_workspace_to_z").get()}},
253 "scan_in_workspace_velocity").get(),
255 "scan_in_workspace_acceleration").get());
364 const float currentYawVel = DatafieldRefPtr::dynamicCast(
367 const float currentPitchVel = DatafieldRefPtr::dynamicCast(
371 FrameTracking::HeadState headState;
372 headState.currentYawPos = currentYaw;
373 headState.currentYawVel = currentYawVel;
374 headState.currentPitchPos = currentPitch;
375 headState.currentPitchVel = currentPitchVel;
378 headState.desiredYawPos = yaw;
379 headState.desiredPitchPos = pitch;
381 struct timespec req = {0, 30 * 1000000L};
389 nanosleep(&req,
nullptr);
397 float velocity,
const Ice::Current&)
413 bool wasGreater =
headYawJoint->getJointValue() > yawFrom;
414 float yawVelocityToInit = wasGreater ? -velocity : velocity;
419 while ((wasGreater &&
headYawJoint->getJointValue() > yawFrom) ||
420 (!wasGreater &&
headYawJoint->getJointValue() < yawFrom))
426 for (
const auto& p: pitchValues)
430 float velocityPitch = wasGreaterP ? -velocity : velocity;
440 bool wasGreaterY = yawFrom > yawTo;
441 float velocityYaw = wasGreaterY ? -velocity : velocity;
444 while ((wasGreaterY &&
headYawJoint->getJointValue() > yawTo) ||
445 (!wasGreaterY &&
headYawJoint->getJointValue() < yawTo))
470 struct timespec req = {0, 30 * 1000000L};
471 for (
const auto& p: points)
473 auto pEigen =
localRobot->toLocalCoordinateSystemVec(ToEigen(p));
479 <<
target.currentPitchPos <<
" - " <<
target.desiredPitchPos;
484 nanosleep(&req,
nullptr);
517 auto posInRobotFrame =
localRobot->toLocalCoordinateSystemVec(frame->getGlobalPosition());
529 float diff =
std::abs(head_state.desiredPitchPos - head_state.currentPitchPos) +
530 std::abs(head_state.currentYawPos - head_state.desiredYawPos);
531 return max_diff > diff;
537 auto posInRobotFrame =
localRobot->toLocalCoordinateSystemVec(frame->getGlobalPosition());
540 if (
std::sqrt(posInRobotFrame.x() * posInRobotFrame.x() + posInRobotFrame.y() * posInRobotFrame.y()) < 300.f)
542 return FrameTracking::HeadState{
true, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f};
549 float yaw = -std::atan2(point.x(), point.y());
557 static_cast<float>(
M_PI) / 8)
562 const auto pointInPitchJointFrame =
headPitchJoint->toLocalCoordinateSystemVec(
563 localRobot->toGlobalCoordinateSystemVec(point));
564 const Eigen::Vector2f pj{pointInPitchJointFrame.y(), pointInPitchJointFrame.z()};
565 const float headHeightRealativeToPitchJoint =
headPitchJoint->toLocalCoordinateSystemVec(
567 float pitch =
headPitchJoint->getJointValue() - std::asin(pj.x() / pj.norm()) +
568 std::asin(headHeightRealativeToPitchJoint / pj.norm());
575 <<
" and pitch=" << pitch;
577 const float currentYawVel = DatafieldRefPtr::dynamicCast(
580 const float currentPitchVel = DatafieldRefPtr::dynamicCast(
584 FrameTracking::HeadState headState;
585 headState.currentYawPos = currentYaw;
586 headState.desiredYawPos = yaw;
587 headState.currentYawVel = currentYawVel;
588 headState.currentPitchPos = currentPitch;
589 headState.desiredPitchPos = pitch;
590 headState.currentPitchVel = currentPitchVel;
595 float yawAcceleration,
float maxPitchVelocity,
float pitchAcceleration)
605 headState.currentYawVel,
608 headState.currentYawPos,
609 headState.desiredYawPos, 1.f);
611 headState.currentPitchVel,
615 headState.currentPitchPos,
616 headState.desiredPitchPos,