7 #include <Eigen/Geometry>
45 memorySubscriber.emplace(configId, srv_->memoryNameSystem);
49 srv_->iceNavigator.createConfig(cfg, configId);
51 navigator.emplace(client::Navigator::InjectedServices{
52 .navigator = &srv_->iceNavigator, .subscriber = &memorySubscriber.value()});
54 return ::armarx::skills::Skill::InitResult{
55 .status = ::armarx::skills::TerminatedSkillStatus::Succeeded};
61 const core::Pose globalTarget = getTargetInFrontOfRoom(in.parameters.room);
71 client::StopEvent se = navigator->waitForStop();
74 ARMARX_INFO <<
"Goal `" << globalTarget.translation() <<
"`reached.";
78 if (se.isSafetyStopTriggeredEvent())
82 return ::armarx::skills::Skill::MainResult{
83 .status = ::armarx::skills::TerminatedSkillStatus::Failed};
85 if (se.isUserAbortTriggeredEvent())
89 return ::armarx::skills::Skill::MainResult{
90 .status = ::armarx::skills::TerminatedSkillStatus::Failed};
92 if (se.isInternalErrorEvent())
95 << se.toInternalErrorEvent().message;
97 return ::armarx::skills::Skill::MainResult{
98 .status = ::armarx::skills::TerminatedSkillStatus::Failed};
103 return ::armarx::skills::Skill::MainResult{
104 .status = ::armarx::skills::TerminatedSkillStatus::Succeeded};
108 GuideHumanToRoom::onStopRequested()
110 if (navigator.has_value())
118 GuideHumanToRoom::getTargetInFrontOfRoom(
const std::string& roomName)
const
120 const algorithms::Costmap costmap = [&]
122 const memory::client::costmap::Reader::Query costmapQuery{
124 .name =
"distance_to_obstacles",
127 const auto result = srv_->costmapReader.query(costmapQuery);
130 return result.costmap.value();
135 const memory::client::rooms::Reader::Query roomQuery{.providerName =
140 const auto result = srv_->roomsReader.query(roomQuery);
141 ARMARX_CHECK(result) <<
"Failed to query room `" << roomName <<
"` from provider `"
143 <<
"`. Reason: " << result.errorMessage;
146 return result.room.value();
150 srv_->virtualRobotReader.getRobotWaiting(properties.
robotName);
154 const core::Pose global_T_robot(robot->getGlobalPose());
156 rooms::RoomNavigationTargetCreator::Params algoParams;
157 rooms::RoomNavigationTargetCreator algo(algoParams);
158 auto result = algo.getClosestPositionOutsideOfRoom(
159 costmap, room, global_T_robot.translation(), &srv_->arviz);
161 const core::Direction dirToRoom = result.global_P_roomEntry - result.global_P_robot;
164 const float yaw = std::atan2(dirToRoom.y(), dirToRoom.x()) - M_PI_2f32;
169 global_T_robot_target.translation() = result.global_P_robot;
170 global_T_robot_target.linear() =
171 Eigen::AngleAxisf(yaw, Eigen::Vector3f::UnitZ()).toRotationMatrix();
173 return global_T_robot_target;