Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dependency_repos.repos
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repositories:
aletheia:
type: git
url: https://github.com/HanielUlises/del-planner.git
version: 084f28067e40dc17e6da1980d84697cfc463b6b1
version: 3bae6286b01cfc62116113a424b63a2eea85c1c0
# The EPDDL grounder plansys2_epddl_grounder runs. It is a plain CMake
# project rather than a ROS package, so colcon builds it as one and installs
# the binary into <prefix>/bin, which puts `plank` on PATH once the workspace
Expand Down
13 changes: 13 additions & 0 deletions eplansys_docs/concepts/architecture.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,19 @@ Parameters are declared under the plugin name at configure time
- ``3``
- Largest number of actions running at once under ``temporal``. The
commutation check enumerates subsets of the running set.
* - ``temporal_estimate``
- string
- ``admissible``
- ``admissible``: the least worst-case makespan. ``critical_path``:
deepen with :math:`\max(h_{\mathrm{adm}}, h_{\mathrm{cp}})`, which
weighs each layer of the relaxed closure by its shortest contributing
action; the policy is admissible but not necessarily the shortest.
* - ``temporal_bound_growth``
- double
- ``1.0``
- Factor by which the search's time bound grows between iterations.
Optimality does not depend on it; ``1.0`` steps to the next lower
bound.
* - ``consistent_beliefs``
- bool
- ``true``
Expand Down
7 changes: 7 additions & 0 deletions plansys2_bringup/params/plansys2_epistemic_params.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,13 @@ planner:
# commutation check enumerates the subsets of the running set, so it
# grows exponentially with this.
max_concurrency: 3
# admissible: the least worst-case makespan. critical_path: a faster,
# satisficing search (relaxed critical path); its policies are valid
# but not necessarily the shortest.
temporal_estimate: "admissible"
# How the search's time bound grows between iterations. Optimality does
# not depend on it; 1.0 steps to the next lower bound.
temporal_bound_growth: 1.0

# The same planning is available from an external Aletheia binary rather
# than in process, through plansys2_aletheia_plan_solver. It takes these
Expand Down
2 changes: 1 addition & 1 deletion plansys2_epistemic_planner/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ find_package(nlohmann_json 3.10 REQUIRED)

# The planning core is Aletheia's, linked as a library rather than copied in,
# so the search here and the epistemic_planner binary are one implementation.
find_package(aletheia 0.3 REQUIRED)
find_package(aletheia 0.4 REQUIRED)

set(EPISTEMIC_SOURCES
src/action_mapping.cpp
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class EpistemicPlanSolver : public PlanSolverBase
std::string consistent_beliefs_parameter_name_;
std::string temporal_parameter_name_;
std::string max_concurrency_parameter_name_;
std::string temporal_estimate_parameter_name_;
std::string temporal_bound_growth_parameter_name_;

/// The last goal the epistemic state published, as text. Latched by the
/// subscription rather than fetched, so reading it costs nothing and cannot
Expand Down
22 changes: 22 additions & 0 deletions plansys2_epistemic_planner/src/epistemic_plan_solver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ void EpistemicPlanSolver::configure(
consistent_beliefs_parameter_name_ = plugin_name + ".consistent_beliefs";
temporal_parameter_name_ = plugin_name + ".temporal";
max_concurrency_parameter_name_ = plugin_name + ".max_concurrency";
temporal_estimate_parameter_name_ = plugin_name + ".temporal_estimate";
temporal_bound_growth_parameter_name_ = plugin_name + ".temporal_bound_growth";

const auto declare = [&](const std::string & name, const std::string & def) {
if (!lc_node_->has_parameter(name)) {
Expand Down Expand Up @@ -220,6 +222,13 @@ void EpistemicPlanSolver::configure(
if (!lc_node_->has_parameter(max_concurrency_parameter_name_)) {
lc_node_->declare_parameter<int>(max_concurrency_parameter_name_, 3);
}
// admissible: the least worst-case makespan. critical_path: deepen with
// max(h_adm, h_cp), an admissible policy found faster on most tasks but not
// necessarily the shortest.
declare(temporal_estimate_parameter_name_, "admissible");
if (!lc_node_->has_parameter(temporal_bound_growth_parameter_name_)) {
lc_node_->declare_parameter<double>(temporal_bound_growth_parameter_name_, 1.0);
}

declare_epddl_parameters(lc_node_, epddl_parameter_names_);

Expand Down Expand Up @@ -489,6 +498,19 @@ std::optional<plansys2_msgs::msg::Plan> EpistemicPlanSolver::getPlan(
std::max<int64_t>(1, lc_node_->get_parameter(max_concurrency_parameter_name_).as_int()));
options.deadline = deadline;

const std::string estimate = parameter(temporal_estimate_parameter_name_);
if (estimate == "critical_path") {
options.estimate = temporal::SearchOptions::Estimate::CriticalPath;
} else if (estimate != "admissible") {
RCLCPP_ERROR(
lc_node_->get_logger(),
"[epistemic] temporal_estimate is '%s'; it must be 'admissible' or 'critical_path'",
estimate.c_str());
return std::nullopt;
}
options.bound_growth = std::max(
1.0, lc_node_->get_parameter(temporal_bound_growth_parameter_name_).as_double());

temporal::SearchStats stats;
const auto durations = durations_from_mapping(task, mapping);
const auto policy = temporal::search_policy(task, durations, options, &stats);
Expand Down
24 changes: 24 additions & 0 deletions plansys2_epistemic_planner/test/temporal_plan_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,3 +140,27 @@ TEST(TemporalPlan, OneAtATimeBranchesOnTheLook)
}
EXPECT_EQ(reports, 2u);
}

TEST(TemporalPlan, TheCriticalPathSearchReturnsAPlanNoShorterThanOptimal)
{
// The satisficing search under max(h_adm, h_cp): valid, serialisable, and
// never shorter than the optimum, which it usually matches.
const auto task = load_task(task_path("robot-fleet-depot"));
const auto mapping = plansys2::ActionMapping::load(mapping_path("robot-fleet-depot"));
const auto durations = plansys2::durations_from_mapping(task, mapping);

temporal::SearchOptions cp;
cp.estimate = temporal::SearchOptions::Estimate::CriticalPath;
const auto satisficing = temporal::search_policy(task, durations, cp);
const auto optimal = temporal::search_policy(task, durations);
ASSERT_TRUE(satisficing.has_value());
ASSERT_TRUE(optimal.has_value());
EXPECT_GE(satisficing->makespan, optimal->makespan - 1e-9);

std::string why;
EXPECT_TRUE(temporal::validate_policy(task, durations, *satisficing, &why)) << why;
std::string error;
const auto plan = plansys2::to_temporal_plan(task, *satisficing, mapping, error);
ASSERT_TRUE(plan.has_value()) << error;
EXPECT_TRUE(plan->temporal);
}
15 changes: 14 additions & 1 deletion plansys2_tests/test_8/test_8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ struct Mission
/// cannot supply, since the task designates both a blocked and a clear world
/// and neither is the model's to choose; the performer reports it on finish,
/// the way a real one would report what its sensor returned.
Mission run_mission(const std::string & observed)
Mission run_mission(const std::string & observed, const std::string & estimate = "admissible")
{
Mission mission;

Expand Down Expand Up @@ -190,6 +190,7 @@ Mission run_mission(const std::string & observed)
planner_node->set_parameter(rclcpp::Parameter("EPISTEMIC.strategy", "aostar"));
// Plan with the mapping's durations and overlap what commutes.
planner_node->set_parameter(rclcpp::Parameter("EPISTEMIC.temporal", true));
planner_node->set_parameter(rclcpp::Parameter("EPISTEMIC.temporal_estimate", estimate));

domain_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE);
problem_node->trigger_transition(lifecycle_msgs::msg::Transition::TRANSITION_ACTIVATE);
Expand Down Expand Up @@ -320,6 +321,18 @@ TEST(test_8, the_looks_overlap_whatever_the_corridor_is)
EXPECT_TRUE(mission.ran("(inspect_corridor r2)")) << describe(mission);
}

TEST(test_8, the_critical_path_search_plans_the_same_mission)
{
// The satisficing search, chosen by parameter: on this mission it finds
// the same overlapping policy, and the mission runs the same way.
const auto mission = run_mission("e-inspect-blocked", "critical_path");
ASSERT_TRUE(mission.temporal);
EXPECT_EQ(mission.result, plansys2_msgs::action::ExecutePlan::Result::SUCCESS)
<< describe(mission);
EXPECT_TRUE(overlapped(mission, "(inspect_corridor r1)", "(inspect_corridor r2)"))
<< describe(mission);
}

// Leave through _exit, so the DDS threads never outlive the process.
//
// rclcpp::shutdown() does not finalise the global context; that happens in
Expand Down
Loading