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
Feature/minimal arbitrator #390
Conversation
Note: The dependency on usdot-fhwa-stol/carma-msgs#19 causes unit tests to break when run against develop branch CARMAMsgs. Unit tests for Arbitrator pass locally when run against the correct CARMAMsgs:
|
/** | ||
* \brief Virtual destructor provided for memory safety | ||
*/ | ||
virtual ~CostFunction(){}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can mark it as pure virtual as well to make sure it will never be called by any child class. This apply to all destructors you have in other abstract class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, defining this as pure virtual seems to remove the ability for my child classes to use the implicit destructor (which seems cleaner to me). I think it'd rather leave this as is, if it's not a big deal.
|
||
namespace arbitrator | ||
{ | ||
template<typename MSrv> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure I get the reason why you template this class.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's just this function that's templated, but it's so it could be used for multiple different kinds of services calls (each needing a different kind of MSrv template parameter for their message type).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I meant this template function. Does arbitrator needs to call anything else than STRATEGIC_PLAN service?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not in the present, thought in the future I believe it probably will. For example it'll need to use a different service to interact with the cost plugins to get their costs for a given plan.
// Normalize the list and invert into costs | ||
for (auto it = plugin_priorities.begin(); it != plugin_priorities.end(); it++) | ||
{ | ||
plugin_costs_[it->first] = 1.0 - (it->second / max_priority); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will be a potential "Divide by Zero" error here if all priorities are not set and default to zero? This also apply to the following compute_cost_per_unit_distance
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it would be. The alternative to throwing a divide by zero exception here would be to catch the exception (or check if it would be thrown) and then throw another exception instead, so I'm not clear if that's any better than just throwing a divide by zero.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the easy way to handle it is to check if max_priority == 0 and assign its cost to infinity/maximum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two small comments.
@qswawrq feel free to merge to develop since freeze has been lifted now. whenever it's ready. thanks. |
PR Details
Description
Implementation of the minimal Arbitrator and mock Plan Delegator nodes.
Adds the
arbitrator
package which contains both the arbitrator library (for unit testing) and arbitrator node proper. Arbitrator consists of a skeleton main function delegating execution flow toarbitrator.cpp
which is primarily structural code that uses a genericPlanningStrategy
to generate plans.TreePlanner
is the only existing implementation ofPlanningStrategy
at present, and is itself generalized overCostFunction
,NeighborGenerator
, andSearchStrategy
for testability and flexibility. The only implementations of these interfaces at present serve to implement a kind of Beam Search that uses the plugins to generate new states, and a list of fixed priorities to derive cost for each state. The search proceeds until a plan reaches the target length or if no new states can be expanded and the length is not reached, the longest plan is returned.The Plan Delegator implementation is extremely minimalistic as this is not the focus of this task. It simply implements enough functionality to receive a maneuver plan and call the
plan_trajectory
service on the associated plugin, finally forwarding the new trajectory on to the Trajectory Executor node.Motivation and Context
These nodes form 2 of the remaining elements of the core CARMA3 planning flow and thus are needed for all future plugin-based planning operation.
How Has This Been Tested?
25 unit tests have been written and passed for all algorithmically relevant components of the Arbitrator (i.e., non-structural, I/O, etc. code). The Plan Delegator node has no unit tests since most of it will be scrapped within the next sprint or two.
Types of changes
Checklist:
CARMA Contributing Guide