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

Define common robotic concepts for code reuse, interporellability #848

Closed
bergercookie opened this issue Oct 22, 2018 · 1 comment
Closed

Comments

@bergercookie
Copy link
Contributor

This is an early attempt to define a set of C++ robotic constructs to
encourage code reuse and interoperability among the various
open-source robotic projects.

These can be implemented in the form of the C++20 concepts TS

More specifically concepts can be used to define and enforce specific
behavior (e.g., methods to be present in a class) for all the
classical robotic constructs that need to be implemented in any new
project. As an example these may include:

  • Pose (2D, 3D, etc.)
  • Graph
  • PointXD / Landmark
  • SensorMeasurement
  • PointCloud
  • ...

Having these constructs in place will allow to define a standard among
the different implementations; one will know what to expect from a
Point instance regardless if they deal with an MRPT CPoint2D, a
JDERobot CPoint3D a custom implementation of theirs or anything else
that could abide to that concept. It will also help to reason about
and benchmark the various implementations.

An example boilerplate code for e.g., a pose would be the following
(does not compile):

// forces every pose object to implement specific methods
template<typename T>
concept bool PoseAble = requires(T a){
{ a.isPDF() } -> bool;
{ a.dims() } -> std::size_t;
{ a.translation() } -> VectorisAble&;
{ a.rotation() } -> RotationMatAble&;
// ...
};

void compose(const PoseAble& p1, const PoseAble& p2)
{
// compose the two poses by calling methods that should
// be present since they implement the `PoseAble`
// concept
}

int main(int argc, char *argv[])
{
PoseAble& p1 = mrpt::poses::CPose2D(1.0, 2.0, M_PI/4.0);
PoseAble& p2 = mrpt::poses::CPose2D(2.0, 3.0, 0.0);

compose(p1, p2);
return 0;
}

P.S. The latest update is that concepts are to be included in C++20
version. There is also a concepts implementation in gcc6 and can be
used by compiling with -fconcepts -std=c++1z

Links

TS Document
Concepts - cppreference
Minimal concepts example

Next actions

To get this going I can create a separate repo and then transfer
ownership to the MRPT org. There we can also discuss the specification
and format of the concepts to be implemented in separate gh-issues
(issue per concept).

How does this all sound to you?
Any ideas for the name? how about robot-concepts?

@jolting, @jlblancoc, @EduFdez,

Adding @eperdices, @okanasik from JDERobot and @rcintas from the Robocomp projects

@bergercookie
Copy link
Contributor Author

Duplicate of #846 - Github is buggy!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant