Skip to content

Commit

Permalink
Return nullptr is goal set is empty
Browse files Browse the repository at this point in the history
Signed-off-by: Yadunund <[email protected]>
  • Loading branch information
Yadunund committed Feb 27, 2024
1 parent 6e01f70 commit d69458e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
7 changes: 6 additions & 1 deletion rmf_task_sequence/src/rmf_task_sequence/events/GoToPlace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,18 @@ Activity::ConstModelPtr GoToPlace::Model::make(
const Parameters& parameters,
const std::vector<Goal>& goals)
{
if (goals.empty())
{
return nullptr;
}

auto invariant_finish_state = invariant_initial_state;

auto selected_goal = goals[0];
std::optional<rmf_traffic::Duration> shortest_travel_time = std::nullopt;
if (invariant_initial_state.waypoint().has_value())
{
for (auto goal: goals)
for (const auto& goal: goals)
{
const auto invariant_duration_opt = estimate_duration(
parameters.planner(),
Expand Down
13 changes: 12 additions & 1 deletion rmf_task_sequence/test/unit/events/test_GoToPlace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ SCENARIO("Test GoToPlace")
{
using GoToPlace = rmf_task_sequence::events::GoToPlace;

auto description = GoToPlace::Description::make_for_one_of({0, 8, 12});
const auto parameters = make_test_parameters();
const auto constraints = make_test_constraints();
const auto now = std::chrono::steady_clock::now();
Expand All @@ -38,8 +37,19 @@ SCENARIO("Test GoToPlace")

const auto travel_estimator = rmf_task::TravelEstimator(*parameters);

WHEN("Goal set is empty")
{
auto description = GoToPlace::Description::make_for_one_of({});
THEN("make_model should return nullptr")
{
const auto model = description->make_model(initial_state, *parameters);
CHECK(model == nullptr);
}
}

WHEN("Not constrained to any map")
{
auto description = GoToPlace::Description::make_for_one_of({0, 8, 12});
const auto model = description->make_model(initial_state, *parameters);
const auto finish = model->estimate_finish(
initial_state, now, *constraints, travel_estimator);
Expand All @@ -50,6 +60,7 @@ SCENARIO("Test GoToPlace")

WHEN("Constrained to the same map")
{
auto description = GoToPlace::Description::make_for_one_of({0, 8, 12});
description->prefer_same_map(true);
const auto model = description->make_model(initial_state, *parameters);
const auto finish = model->estimate_finish(
Expand Down

0 comments on commit d69458e

Please sign in to comment.