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 basic double, vector and matrix operations on signals #26

Open
jviereck opened this issue Jan 27, 2019 · 10 comments
Open

Provide basic double, vector and matrix operations on signals #26

jviereck opened this issue Jan 27, 2019 · 10 comments

Comments

@jviereck
Copy link
Contributor

At this point doing basic algebraic operations with signals like adding two vector-signals or slicing a matrix requires using matrix/operator entities from sot-core 1. For convenience it would be great to have basic operators like addition, substraction, multiplication (including matrix-vector products etc) work on the python signals class directly. Like

slider_a = robot.device.slider_values[1] # Return a signal of type double
dg.plug([1, 1] * slider_a, pd.Kp)

etc.

Does this sounds like a good idea? It would required to move the sot-core matrix/operators into this repo.

@nim65s
Copy link
Contributor

nim65s commented Jan 28, 2019

Hi,

I think this would be the right thing to do, but we are currently looking at removing this project in favor of another python binding for dynamic-graph, which would be compatible with Python3, so I think this should be done directly in this new project.

@jviereck
Copy link
Contributor Author

@nim65s, sounds good. Any chance to take a look at the new project? I tried to compile python2 on my mac and it fails -would be more than happy to try the new one on osx with python3.

@jmirabel
Copy link
Contributor

jmirabel commented Jan 28, 2019

Hi,

I had the same idea as you. It is actually easy to do. I started it on branch python_expression on my fork (https://github.com/jmirabel/dynamic-graph-python/tree/python_expression).
As far as I remember, the biggest issues are:

  • the difficulty to get the type of a signal,
  • the fact that SoT does not handle unnamed entities nor provide a tool to generate unique names.

The two points are not very hard to solve though.

@nim65s
Copy link
Contributor

nim65s commented Jan 28, 2019

It is far from ready for now, but the first stages of development are available here: https://github.com/nim65s/py-dynamic-graph

I am currently trying different ways to bind eigen, so stack-of-tasks/eigenpy#35 is also makint troubles here. I also tried pybind11, but the project, even if it looks really nice and promising, seems to suffer from lack of maintenance time.

Don't expect too much for this now, as this is not my main task, and I might not be the best guy to develop this.

@olivier-stasse
Copy link
Member

Sorry for the long delay in follow up on this. I really like the overall idea of having operators at the python level to manipulate signals. We could use template to automatically include new types.
I am not however fully sure that we need to move the types from sot-core.
I prefer to have atomic packages and add new types incrementally.

@jviereck
Copy link
Contributor Author

@olivier-stasse , thanks for your take on this.

I am not however fully sure that we need to move the types from sot-core.

I am not sure what you are referring to with "types from sot-core" here. Is type something like dg:Vector or you refer to something else?

@MaximilienNaveau
Copy link

Hi, any update on this project?

@jmirabel
Copy link
Contributor

From LAAS, no and this is not in the roadmap.

@olivier-stasse
Copy link
Member

@jviereck we still have some issues with the new bindings on some of our repositories. But normally the bindings with python3 is working very well now.

So if I understand correctly you want to build the graph of the signal using directly some algebra ?

@jmirabel
Copy link
Contributor

jmirabel commented Mar 3, 2021

Now that we moved to boost python, it wouldn't be hard to achieve. Here are the steps, in case someone wants to work on this:

  1. in C++, create the operators you are interested in, like
Signal<MatrixHomo>& operator* (Signal<MatrixHomo>& a, Signal<MatrixHomo>& b) {
// Create entity MatrixHomoProduct, and register it in the pool.
// plug the signals
return entity.sout;
}
  1. Expose it to Python by adding .def(self * self) to the bp::class_<Signal<MatrixHomo>>.

The only annoying this is that the operation entity is not easily accessible.

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

5 participants