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

Provide a setting for charge tasks to run indefinitely #99

Merged
merged 2 commits into from
Oct 11, 2023
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
10 changes: 10 additions & 0 deletions rmf_task/include/rmf_task/requests/ChargeBattery.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@ class ChargeBattery
const State& initial_state,
const Parameters& parameters) const final;

/// Set the charging task to run indefinitely. This means it will never
/// declare itself as finished and must instead be canceled. This can be
/// used for idle tasks that are canceled automatically when a task request
/// comes in. If indefinite is false, the robot will charge up to its
/// designated recharge level.
void set_indefinite(bool value);

/// Should this recharge task run indefinitely?
bool indefinite() const;

class Implementation;
private:
Description();
Expand Down
10 changes: 10 additions & 0 deletions rmf_task/include/rmf_task/requests/ChargeBatteryFactory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,16 @@ class ChargeBatteryFactory : public RequestFactory
const std::string& requester,
std::function<rmf_traffic::Time()> time_now_cb);

/// Set the charging task to run indefinitely. This means it will never
/// declare itself as finished and must instead be canceled. This can be used
/// for idle tasks that are canceled automatically when a task request comes
/// in. If indefinite is false, the robot will charge up to its designated
/// recharge level.
void set_indefinite(bool value);

/// Does this factory produce charging requests that will run indefinitely?
bool indefinite() const;

/// Documentation inherited
ConstRequestPtr make_request(const State& state) const final;

Expand Down
18 changes: 16 additions & 2 deletions rmf_task/src/rmf_task/requests/ChargeBattery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,8 @@ ChargeBattery::Model::Model(

//==============================================================================
std::optional<rmf_task::Estimate>
ChargeBattery::Model::estimate_finish(const State& initial_state,
ChargeBattery::Model::estimate_finish(
const State& initial_state,
const Constraints& task_planning_constraints,
const TravelEstimator& travel_estimator) const
{
Expand Down Expand Up @@ -162,7 +163,8 @@ rmf_traffic::Duration ChargeBattery::Model::invariant_duration() const
//==============================================================================
class ChargeBattery::Description::Implementation
{

public:
bool indefinite = false;
};

//==============================================================================
Expand Down Expand Up @@ -201,6 +203,18 @@ auto ChargeBattery::Description::generate_info(
};
}

//==============================================================================
void ChargeBattery::Description::set_indefinite(bool value)
{
_pimpl->indefinite = value;
}

//==============================================================================
bool ChargeBattery::Description::indefinite() const
{
return _pimpl->indefinite;
}

//==============================================================================
ConstRequestPtr ChargeBattery::make(
rmf_traffic::Time earliest_start_time,
Expand Down
13 changes: 13 additions & 0 deletions rmf_task/src/rmf_task/requests/ChargeBatteryFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ChargeBatteryFactory::Implementation
public:
std::optional<std::string> requester;
std::function<rmf_traffic::Time()> time_now_cb;
bool indefinite = false;
};

//==============================================================================
Expand All @@ -47,6 +48,18 @@ ChargeBatteryFactory::ChargeBatteryFactory(
// Do nothing
}

//==============================================================================
void ChargeBatteryFactory::set_indefinite(bool value)
{
_pimpl->indefinite = value;
}

//==============================================================================
bool ChargeBatteryFactory::indefinite() const
{
return _pimpl->indefinite;
}

//==============================================================================
ConstRequestPtr ChargeBatteryFactory::make_request(const State& state) const
{
Expand Down
Loading