Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow fleet adapters to change participant profiles #229

Merged
merged 7 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from 6 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
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ class RobotUpdateHandle
/// Get the schedule participant of this robot
rmf_traffic::schedule::Participant* get_participant();

/// Change the radius of the footprint and vicinity of this participant.
void change_participant_profile(
double footprint_radius,
double vicinity_radius);

/// Override the schedule to say that the robot will be holding at a certain
/// position. This should not be used while tasks with automatic schedule
/// updating are running, or else the traffic schedule will have jumbled up
Expand Down
36 changes: 36 additions & 0 deletions rmf_fleet_adapter/src/rmf_fleet_adapter/agv/RobotUpdateHandle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include "internal_RobotUpdateHandle.hpp"
#include "../TaskManager.hpp"

#include <rmf_traffic/geometry/Circle.hpp>

#include <rmf_traffic_ros2/Time.hpp>

#include <iostream>
Expand Down Expand Up @@ -687,6 +689,40 @@ RobotUpdateHandle::Unstable::get_participant()
return nullptr;
}

//==============================================================================
void RobotUpdateHandle::Unstable::change_participant_profile(
double footprint_radius,
double vicinity_radius)
{
const auto vicinity = [&]() -> rmf_traffic::geometry::FinalConvexShapePtr
{
if (vicinity_radius <= footprint_radius)
return nullptr;

return rmf_traffic::geometry::make_final_convex(
rmf_traffic::geometry::Circle(vicinity_radius));
} ();

const auto footprint = rmf_traffic::geometry::make_final_convex(
rmf_traffic::geometry::Circle(footprint_radius));

rmf_traffic::Profile profile(footprint, vicinity);
if (const auto context = _pimpl->get_context())
{
context->worker().schedule(
[
w = context->weak_from_this(),
profile = std::move(profile)
](const auto&)
{
if (const auto context = w.lock())
{
context->itinerary().change_profile(profile);
}
});
}
}

//==============================================================================
void RobotUpdateHandle::Unstable::declare_holding(
std::string on_map,
Expand Down
10 changes: 10 additions & 0 deletions rmf_fleet_adapter_python/src/adapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,16 @@ PYBIND11_MODULE(rmf_adapter, m) {
},
py::return_value_policy::reference_internal,
"Experimental API to access the schedule participant")
.def("unstable_change_participant_profile",
[&](agv::RobotUpdateHandle& self,
double footprint_radius,
double vicinity_radius)
{
self.unstable().change_participant_profile(
footprint_radius, vicinity_radius);
},
py::arg("footprint_radius"),
py::arg("vicinity_radius"))
.def("unstable_declare_holding",
[&](agv::RobotUpdateHandle& self,
std::string on_map,
Expand Down