-
Notifications
You must be signed in to change notification settings - Fork 58
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
EasyFullControl API #189
EasyFullControl API #189
Conversation
Signed-off-by: Xi Yu Oh <xiyu@openrobotics.org>
Codecov Report
@@ Coverage Diff @@
## main #189 +/- ##
==========================================
+ Coverage 17.61% 17.87% +0.26%
==========================================
Files 209 418 +209
Lines 19351 38138 +18787
Branches 9297 18248 +8951
==========================================
+ Hits 3409 6819 +3410
- Misses 12274 24000 +11726
- Partials 3668 7319 +3651
Flags with carried forward coverage won't be shown. Click here to find out more. |
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.
Thanks for getting started on this. Couple of comments for your consideration.
bool add_robot( | ||
const std::string& name, | ||
const Eigen::Vector3d& pose, | ||
std::function<Eigen::Vector3d()> get_position, |
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.
Let's alias the type of some of these parameters similar to what you have defined to ProcessCompleted
.
Eg.
using GetPosition = std::function<Eigen::Vector3d()>;
bool add_robot(
...
GetPosition get_position,
...);
|
||
bool add_robot( | ||
const std::string& name, | ||
const Eigen::Vector3d& pose, |
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.
Maybe instead of Eigen::Vector3d
, this could be a
using Start = std::variant<rmf_traffic::agv::Planner::Start, Eigen::Vector3d>;
...
bool add_robot(
...
Start start
...);
This would allow users to either submit a known Panner:Start
or a pose. In the latter case, we will use compute_plan_starts
to estimate the start.
ActionExecutor action_executor); | ||
|
||
private: | ||
EasyFullControl(); |
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.
Use PIMPL pattern
class EasyFullControl : public std::enable_shared_from_this<EasyFullControl> | ||
{ | ||
public: | ||
|
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.
Add a static make()
function which will initialize and spin an Adapter
.
{ | ||
public: | ||
|
||
using ProcessCompleted = std::function<bool(const std::string& id)>; |
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.
Since a ProcessCompleted
is returned for a specific request, we do not need to give it a string id
to get feedback. The internal implementation will store a map.
const Eigen::Vector3d& pose, | ||
std::function<Eigen::Vector3d()> get_position, | ||
std::function<ProcessCompleted(const Eigen::Vector3d pose)> navigate, | ||
ActionExecutor action_executor); |
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.
We would also need to accept an object that allows us to perform coordinate transformation between RMF and robot map frames. We could create a class Transformation
subclass that stores Eigen Transform2D/Affine objects to convert between RMF <> Robot coordinates
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.
On second thought, ignore this. If the documentation makes it explicit that all coordinates are in RMF coordinate frame, then we do not have to worry about this.
Signed-off-by: Xi Yu Oh <xiyu@openrobotics.org>
@Yadunund Thanks for the comments, addressed them in the latest commit. Also added a |
const std::string& name, | ||
Start pose, | ||
GetPosition get_position, | ||
std::function<ProcessCompleted(const Eigen::Vector3d pose)> navigate, |
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'm not super sure about this navigate
callback. I understand how it would work: We issue a navigation command by triggering this callback, then we get back a new callback that we can poll to figure out if the robot has finished navigating.
What I would've expected is something more like this:
std::function<void(const Eigen::Vector3d pose, std::function<void()> notify_finished)> navigate
We would trigger this navigate callback and provide the user with:
- the pose we want the robot to navigate to
- a callback for the user to trigger when the robot has reached its goal
I do understand the appeal of the current design: The user is less fallible because by polling we can demand to know whether the robot is finished yet, whereas giving them a callback to trigger means we're relying on them to remember to trigger it eventually.
However, I think from the user's point of view it will probably be easier for them to just store a callback that they will trigger when their navigating is finished, rather than write a callback that can correctly report whether the destination has been reached whenever it is called. It would also fit better in a reactive programming paradigm.
I don't feel super strongly about this since the current API could absolutely work. Any preference between the two approaches is pretty subjective, so I'd be interested in hearing other people's opinions.
/// \param[in] navigate | ||
/// The API function for navigating your robot to a pose. | ||
/// Returns a ProcessCompleted callback to check status of navigation task. | ||
/// |
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 seems to me like the add_robot
function is missing a callback that would let us command the robot to stop immediately. That feature in the RobotCommandHandle does get used sometimes.
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 we're also missing something for dock commands.
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 didn't mention in this PR that i'm continuing the work on open-rmf's feature/easy_full_control
branch. I added the stop callback there, but let me push some updates from today there as well
Closed, continuing on #235 |
This PR introduces an
EasyFullControl
API for users to initialize robots and set important API functions as callbacks. This provides an easy way of creating their own adapters and also prevents them from having to update the internals of their modified code manually when new changes are pushed.