diff --git a/mock/cpp_mock_scenarios/src/spawn/spawn_in_map_frame.cpp b/mock/cpp_mock_scenarios/src/spawn/spawn_in_map_frame.cpp index 56d48813a89..e4c308a6854 100644 --- a/mock/cpp_mock_scenarios/src/spawn/spawn_in_map_frame.cpp +++ b/mock/cpp_mock_scenarios/src/spawn/spawn_in_map_frame.cpp @@ -41,7 +41,7 @@ class SpawnInMapFrameScenario : public cpp_mock_scenarios::CppScenarioNode const auto map_pose = traffic_simulator::pose::toMapPose( traffic_simulator::helper::constructCanonicalizedLaneletPose( 120545, 0.0, 0.0, api_.getHdmapUtils())); - if (api_.reachPosition("ego", map_pose, 0.1)) { + if (api_.getEntity("ego")->reachPosition(map_pose, 0.1)) { stop(cpp_mock_scenarios::Result::SUCCESS); } else { stop(cpp_mock_scenarios::Result::FAILURE); diff --git a/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action.cpp b/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action.cpp index 42140bbee4c..a9c3a99e6c6 100644 --- a/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action.cpp +++ b/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action.cpp @@ -44,11 +44,14 @@ class SynchronizedAction : public cpp_mock_scenarios::CppScenarioNode void onUpdate() override { + auto npc = api_.getEntity("npc"); + auto ego = api_.getEntity("ego"); + // SUCCESS if ( - api_.requestSynchronize("npc", "ego", ego_target, npc_target, 0, 0.5) && - api_.reachPosition("ego", ego_target, 1.0) && api_.reachPosition("npc", npc_target, 1.0) && - api_.getCurrentTwist("npc").linear.x < 0.5) { + npc->requestSynchronize("ego", ego_target, npc_target, 0, 0.5) && + ego->reachPosition(ego_target, 1.0) && npc->reachPosition(npc_target, 1.0) && + npc->getCurrentTwist().linear.x < 0.5) { stop(cpp_mock_scenarios::Result::SUCCESS); } @@ -67,24 +70,29 @@ class SynchronizedAction : public cpp_mock_scenarios::CppScenarioNode traffic_simulator::helper::constructCanonicalizedLaneletPose( 34976, 20, 0, api_.getHdmapUtils()), getVehicleParameters()); - api_.setLinearVelocity("ego", 3); - api_.requestSpeedChange("ego", 3, true); + + auto ego = api_.getEntity("ego"); + ego->setLinearVelocity(3); + ego->requestSpeedChange(3, true); std::vector goal_poses; goal_poses.emplace_back(traffic_simulator::helper::constructCanonicalizedLaneletPose( 34579, 20, 0, api_.getHdmapUtils())); - api_.requestAssignRoute("ego", goal_poses); + ego->requestAssignRoute(goal_poses); api_.spawn( "npc", traffic_simulator::helper::constructCanonicalizedLaneletPose( 34576, 0, 0, api_.getHdmapUtils()), getVehicleParameters()); + + auto npc = api_.getEntity("npc"); + std::vector npc_goal_poses; npc_goal_poses.emplace_back(traffic_simulator::helper::constructCanonicalizedLaneletPose( 34564, 20, 0, api_.getHdmapUtils())); - api_.requestAssignRoute("npc", npc_goal_poses); - api_.setLinearVelocity("npc", 6); + npc->requestAssignRoute(npc_goal_poses); + npc->setLinearVelocity(6); } auto getSampleLaneletPose(const traffic_simulator::LaneletPose & lanelet_pose) diff --git a/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action_with_speed.cpp b/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action_with_speed.cpp index 2aa571173fa..5395b90f857 100644 --- a/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action_with_speed.cpp +++ b/mock/cpp_mock_scenarios/src/synchronized_action/synchronized_action_with_speed.cpp @@ -44,11 +44,14 @@ class SynchronizedActionWithSpeed : public cpp_mock_scenarios::CppScenarioNode void onUpdate() override { + auto npc = api_.getEntity("npc"); + auto ego = api_.getEntity("ego"); + // SUCCESS if ( - api_.requestSynchronize("npc", "ego", ego_target, npc_target, 2, 0.5) && - api_.reachPosition("ego", ego_target, 1.0) && api_.reachPosition("npc", npc_target, 1.0) && - api_.getCurrentTwist("npc").linear.x < 2.5) { + npc->requestSynchronize("ego", ego_target, npc_target, 2, 0.5) && + ego->reachPosition(ego_target, 1.0) && npc->reachPosition(npc_target, 1.0) && + npc->getCurrentTwist().linear.x < 2.5) { stop(cpp_mock_scenarios::Result::SUCCESS); } @@ -67,24 +70,29 @@ class SynchronizedActionWithSpeed : public cpp_mock_scenarios::CppScenarioNode traffic_simulator::helper::constructCanonicalizedLaneletPose( 34976, 20, 0, api_.getHdmapUtils()), getVehicleParameters()); - api_.setLinearVelocity("ego", 3); - api_.requestSpeedChange("ego", 3, true); + + auto ego = api_.getEntity("ego"); + ego->setLinearVelocity(3); + ego->requestSpeedChange(3, true); std::vector goal_poses; goal_poses.emplace_back(traffic_simulator::helper::constructCanonicalizedLaneletPose( 34579, 20, 0, api_.getHdmapUtils())); - api_.requestAssignRoute("ego", goal_poses); + ego->requestAssignRoute(goal_poses); api_.spawn( "npc", traffic_simulator::helper::constructCanonicalizedLaneletPose( 34576, 0, 0, api_.getHdmapUtils()), getVehicleParameters()); + + auto npc = api_.getEntity("npc"); + std::vector npc_goal_poses; npc_goal_poses.emplace_back(traffic_simulator::helper::constructCanonicalizedLaneletPose( 34564, 20, 0, api_.getHdmapUtils())); - api_.requestAssignRoute("npc", npc_goal_poses); - api_.setLinearVelocity("npc", 6); + npc->requestAssignRoute(npc_goal_poses); + npc->setLinearVelocity(6); } auto getSampleLaneletPose(const traffic_simulator::LaneletPose & lanelet_pose) diff --git a/mock/cpp_mock_scenarios/src/traffic_simulation_demo.cpp b/mock/cpp_mock_scenarios/src/traffic_simulation_demo.cpp index 251a2806cf3..d53b4cd426e 100644 --- a/mock/cpp_mock_scenarios/src/traffic_simulation_demo.cpp +++ b/mock/cpp_mock_scenarios/src/traffic_simulation_demo.cpp @@ -163,7 +163,7 @@ class TrafficSimulationDemoScenario : public cpp_mock_scenarios::CppScenarioNode "obstacle", traffic_simulator::helper::constructPose(10, 5, 0, 0, 0, -1.57), getMiscObjectParameters()); api_.getEntity("obstacle") - ->setCanonicalizedStatus( + ->setStatus( ego_entity->getMapPose(), traffic_simulator::helper::constructPose(10, 5, 0, 0, 0, -1.57), traffic_simulator::helper::constructActionStatus());