-
Notifications
You must be signed in to change notification settings - Fork 18
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
have addSignalFunction support tuples or lists #11
Comments
We could definitely do that. Note, you can also do something like this: addSignalFunction('EST_ROBOT_STATE', lambda x: rpyFunction(x)[0], label='roll') This might work fine for most purposes, but it will be slightly less efficient since it calls the quat_to_euler conversion three times. We could definitely add new support for multi component signals, and that might introduce some nice features and generalities. You could then add support for applying common functions to the signals, conversions that are commonly used like quat-to-rpy, magnitude, component filters, etc. |
Note, you will need to pull signal-scope master in order to get the "label" keyword argument that I used in my previous reply. |
Oh wait, the example I posted won't quite work, don't try it. I'll post a working version in a minute. |
Yeah it would have to be another function wrapper like: def extractComponent(func, idx): def f(msg): t, v = func(msg) return t, v[idx] return f def rpyFunction(msg): quat = quat_to_euler([msg.pose.rotation.w, msg.pose.rotation.x, msg.pose.rotation.y, msg.pose.rotation.z]) rpy = (quat) return msg.utime, rpy addSignalFunction('EST_ROBOT_STATE', extractComponent(rpyFunction, 0), label='roll') addSignalFunction('EST_ROBOT_STATE', extractComponent(rpyFunction, 1), label='pitch') addSignalFunction('EST_ROBOT_STATE', extractComponent(rpyFunction, 2), label='yaw') |
The snippet below fails as it requires a single float as output:
def rpyFunction(msg):
quat = quat_to_euler([msg.pose.rotation.w, msg.pose.rotation.x, msg.pose.rotation.y, msg.pose.rotation.z])
rpy = (quat)
return msg.utime, rpy
addSignalFunction('EST_ROBOT_STATE', rpyFunction)
The text was updated successfully, but these errors were encountered: