9 #include <Eigen/Geometry>
11 #include <VirtualRobot/VirtualRobot.h>
56 memorySubscriber.emplace(configId, srv_->memoryNameSystem);
60 srv_->iceNavigator.createConfig(cfg, configId);
62 navigator.emplace(client::Navigator::InjectedServices{
63 .navigator = &srv_->iceNavigator, .subscriber = &memorySubscriber.value()});
65 return ::armarx::skills::Skill::InitResult{
66 .status = ::armarx::skills::TerminatedSkillStatus::Succeeded};
72 const core::Pose globalTarget = getTargetInFrontOfRoom(in.parameters.room);
82 client::StopEvent se = navigator->waitForStop();
85 ARMARX_INFO <<
"Goal `" << globalTarget.translation() <<
"`reached.";
89 if (se.isSafetyStopTriggeredEvent())
93 return ::armarx::skills::Skill::MainResult{
94 .status = ::armarx::skills::TerminatedSkillStatus::Failed};
96 if (se.isUserAbortTriggeredEvent())
100 return ::armarx::skills::Skill::MainResult{
101 .status = ::armarx::skills::TerminatedSkillStatus::Failed};
103 if (se.isInternalErrorEvent())
106 << se.toInternalErrorEvent().message;
108 return ::armarx::skills::Skill::MainResult{
109 .status = ::armarx::skills::TerminatedSkillStatus::Failed};
114 return ::armarx::skills::Skill::MainResult{
115 .status = ::armarx::skills::TerminatedSkillStatus::Succeeded};
119 GuideHumanToRoom::onStopRequested()
121 if (navigator.has_value())
129 GuideHumanToRoom::getTargetInFrontOfRoom(
const std::string& roomName)
const
131 const algorithms::Costmap costmap = [&]
133 const memory::client::costmap::Reader::Query costmapQuery{
135 .name =
"distance_to_obstacles",
138 const auto result = srv_->costmapReader.query(costmapQuery);
141 return result.costmap.value();
146 const memory::client::rooms::Reader::Query roomQuery{.providerName =
151 const auto result = srv_->roomsReader.query(roomQuery);
152 ARMARX_CHECK(result) <<
"Failed to query room `" << roomName <<
"` from provider `"
154 <<
"`. Reason: " << result.errorMessage;
158 return result.rooms.front();
162 srv_->virtualRobotReader.getRobotWaiting(properties.
robotName);
166 const core::Pose global_T_robot(robot->getGlobalPose());
168 rooms::RoomNavigationTargetCreator::Params algoParams;
169 rooms::RoomNavigationTargetCreator algo(algoParams);
170 auto result = algo.getClosestPositionOutsideOfRoom(
171 costmap, room, global_T_robot.translation(), &srv_->arviz);
173 const core::Direction dirToRoom = result.global_P_roomEntry - result.global_P_robot;
176 const float yaw = std::atan2(dirToRoom.y(), dirToRoom.x()) - M_PI_2f32;
181 global_T_robot_target.translation() = result.global_P_robot;
182 global_T_robot_target.linear() =
183 Eigen::AngleAxisf(yaw, Eigen::Vector3f::UnitZ()).toRotationMatrix();
185 return global_T_robot_target;