Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/RJD-1057-remove-functions-forwar…
Browse files Browse the repository at this point in the history
…ded-to-entity-base-refactor' into ref/RJD-1057-improve-responsibility-simulator-core-api
  • Loading branch information
dmoszynski committed Oct 14, 2024
2 parents 3868f03 + 0149eec commit e4b96cb
Showing 1 changed file with 21 additions and 24 deletions.
45 changes: 21 additions & 24 deletions mock/cpp_mock_scenarios/src/random_scenario/random001.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -182,34 +182,31 @@ class RandomScenario : public cpp_mock_scenarios::CppScenarioNode
spawn_and_cross_pedestrian(i);
}

{
const auto trigger_position = traffic_simulator::helper::constructLaneletPose(34621, 10, 0.0);
const auto ego_goal_position =
traffic_simulator::helper::constructLaneletPose(34606, 0.0, 0.0);
const auto entity_name = "spawn_nearby_ego";

if (ego_entity->isInPosition(trigger_position, 20.0) && !api_.isEntitySpawned(entity_name)) {
api_.spawn(
entity_name,
traffic_simulator::pose::transformRelativePoseToGlobal(
ego_entity->getMapPose(),
geometry_msgs::build<geometry_msgs::msg::Pose>()
.position(geometry_msgs::build<geometry_msgs::msg::Point>().x(10).y(-5).z(0))
.orientation(geometry_msgs::msg::Quaternion())),
getVehicleParameters(),
traffic_simulator::entity::VehicleEntity::BuiltinBehavior::doNothing());
}
const auto trigger_position = traffic_simulator::helper::constructLaneletPose(34621, 10, 0.0);
constexpr auto entity_name = "spawn_nearby_ego";
if (ego_entity->isInPosition(trigger_position, 20.0) && !api_.isEntitySpawned(entity_name)) {
api_.spawn(
entity_name,
traffic_simulator::pose::transformRelativePoseToGlobal(
ego_entity->getMapPose(),
geometry_msgs::build<geometry_msgs::msg::Pose>()
.position(geometry_msgs::build<geometry_msgs::msg::Point>().x(10).y(-5).z(0))
.orientation(geometry_msgs::msg::Quaternion())),
getVehicleParameters(),
traffic_simulator::entity::VehicleEntity::BuiltinBehavior::doNothing());
}

if (!ego_entity->isInPosition(trigger_position, 20.0) && api_.isEntitySpawned(entity_name)) {
api_.despawn(entity_name);
}
if (!ego_entity->isInPosition(trigger_position, 20.0) && api_.isEntitySpawned(entity_name)) {
api_.despawn(entity_name);
}

if (ego_entity->isInPosition(ego_goal_position, 1.0)) {
api_.despawn("ego");
stop(cpp_mock_scenarios::Result::SUCCESS);
}
const auto ego_goal_position = traffic_simulator::helper::constructLaneletPose(34606, 0.0, 0.0);
if (ego_entity->isInPosition(ego_goal_position, 1.0)) {
api_.despawn("ego");
stop(cpp_mock_scenarios::Result::SUCCESS);
}
}

void onInitialize() override
{
// api_.setVerbose(true);
Expand Down

0 comments on commit e4b96cb

Please sign in to comment.