hungpham2511 / toppra

robotic motion planning library
https://hungpham2511.github.io/toppra/index.html
MIT License
625 stars 170 forks source link

[cpp] Add CartesianVelocityNorm and an implemention with Pinocchio #146

Closed jmirabel closed 3 years ago

jmirabel commented 3 years ago

Partially fixes #101 and is related to #144

From the doxygen doc: image

jmirabel commented 3 years ago

@hungpham2511 let me know if I should care of the two CI failures.

hungpham2511 commented 3 years ago

Great! Flawless work as always. Many thanks! @jmirabel

I wonder if S should be constrained to being positive-definite.

hungpham2511 commented 3 years ago

Ah, my bad for not reading the description of S and J. It will always be semi-positive definite at least then.

@hungpham2511 let me know if I should care of the two CI failures.

These two are deprecated. I will remove them shortly.

hungpham2511 commented 3 years ago

By the way, Joseph, would you like to be the code owner for the cpp codebase? Basically, if there are PRs touching the cpp code, you will get notified and invited to review.

jmirabel commented 3 years ago

By the way, Joseph, would you like to be the code owner for the cpp codebase? Basically, if there are PRs touching the cpp code, you will get notified and invited to review.

At the moment, I prefer to leave it as it is. I don't always get the time necessary for a correct review and prefer not to block anyone.

mrunaljsarvaiya commented 2 years ago

Does anyone happen to have a python example for this?

jmirabel commented 2 years ago

Check the C++ unit tests. They should be straightforward to convert into python code.

You can open a PR with an example if you have something that works.

mrunaljsarvaiya commented 2 years ago

Check the C++ unit tests. They should be straightforward to convert into python code.

You can open a PR with an example if you have something that works.

I'm a newbie to python bindings, how would I import the CartesianVelocityNorm constraint?

After import toppra.cpp as tac, tac.bindings_loaded() always returns False.

from toppra.cpp.toppra_int import * returns an error ModuleNotFoundError: No module named 'toppra.cpp.toppra_int'

jmirabel commented 2 years ago

You haven't installed the C++ bindings then. Install them and try again.

mrunaljsarvaiya commented 2 years ago

Yeah that's correct, I managed to install the python bindings and am able to import CartesianVelocityNorm. Based on the cpp test as an example, is the next step to build a class that derives from CartesianVelocityNorm and define the computeVelocity and computeVelocityLimit method?

Also since the init header is CartesianVelocityNorm (const Matrix& S, const double& limit) in the cpp file, in python would I initialize it with the inputs being an numpy ndarray and float?

Or after taking a closer look at the bindings/constraint.cpp file, the python interface method would be py::init([](py::object model, const Matrix& S, const double& limit, int frame_id), i.e I need a pinocchio model of my system?

mrunaljsarvaiya commented 2 years ago

If BUILD_WITH_PINOCCHIO=True and PINOCCHIO_WITH_PYTHON_INTERFACE=False, the constraints.cpp file will build the following py functions for jointTorque py::class_<Pinocchio<>, std::shared_ptr<Pinocchio<> >, JointTorque>( mod_jointTorque, "Pinocchio") .def(py::init<const std::string&, const Vector&>(), py::arg("urdfFilename"), py::arg("frictionCoeffs") = Vector())

however, the equivalent condition for cartesianVelocityNorm builds the following

py::class_<Pinocchio<>, std::shared_ptr<Pinocchio<> >, CartesianVelocityNorm>( mod_jointTorque, "Pinocchio")

Is there a .def(py.. . missing?

Apologies for the stream of questions here

jmirabel commented 2 years ago

You can't create objects of type cartesianVelovityNorm::Pinocchio in Python without Pinocchio python bindings.

I suggest you install Pinocchio Python bindings and recompile with the relevant CMake flags. This is the easiest way.

rajkumar2804 commented 1 year ago

Do we have any constant Cartesian speed (magnitude of velocity) implementation example , I looked into the test case but that doesn't help much.

jmirabel commented 1 year ago

@mrunaljsarvaiya may have an example.

The first thing you should do is to make sure you have pinocchio installed with python bindings. Then compile this project with the relevant cmake flags (you can use ccmake or another cmake gui of your choice).