Hi Tylan,
Unfortunately, finding the max element across time like this is not possible in Moco. You could technically calculate the maximum value over time, but the "max()" operation is non-smooth and won't play nice with direct collocation.
As an alternative, instead of using a max() function, you could set the hand velocity to a large exponent in the integrand which will approximate the maximum hand velocity.
Best,
Nick
Maximize Velocity of a Body Segment
- Nicholas Bianco
- Posts: 1000
- Joined: Thu Oct 04, 2012 8:09 pm
- Evan Dooley
- Posts: 33
- Joined: Sun Nov 24, 2019 11:17 am
Re: Maximize Velocity of a Body Segment
Hi Ty,
I'm not sure about the starting the new goal problem, but for your previous question about being able to get the value from a Vec3 to be usable I've had success with the command "osimVec3ToArray()" where the input between the parentheses is the Vec3 object. This returns a 1x3 matrix that you can then use the values of to do calculations.
However, the vec3Obj.get(index) that you have above should work as well, so I might also double check that "hand.getOutput('linear_velocity')" is actually returning a "Vec3" object.
Good luck,
Evan
I'm not sure about the starting the new goal problem, but for your previous question about being able to get the value from a Vec3 to be usable I've had success with the command "osimVec3ToArray()" where the input between the parentheses is the Vec3 object. This returns a 1x3 matrix that you can then use the values of to do calculations.
However, the vec3Obj.get(index) that you have above should work as well, so I might also double check that "hand.getOutput('linear_velocity')" is actually returning a "Vec3" object.
Good luck,
Evan
- Tylan Templin
- Posts: 40
- Joined: Mon Jan 15, 2018 10:55 am
Re: Maximize Velocity of a Body Segment
Hi Nick,
The solution of setting the hand velocity to a high exponent seems to be a nice solution. Thanks!
And Evan, 'linear_velocity' should be a Vec3 but I was trying to use it as an Output Goal so it was stored differently and I wasn't able to use the Vec3 operations. But I think I have a useful way to get around it with the custom goal and Nick's advice to set a high exponent for the velocity.
Thanks!
Ty
The solution of setting the hand velocity to a high exponent seems to be a nice solution. Thanks!
And Evan, 'linear_velocity' should be a Vec3 but I was trying to use it as an Output Goal so it was stored differently and I wasn't able to use the Vec3 operations. But I think I have a useful way to get around it with the custom goal and Nick's advice to set a high exponent for the velocity.
Thanks!
Ty
- Aravind Sundararajan
- Posts: 17
- Joined: Mon Aug 29, 2016 2:59 pm
Re: Maximize Velocity of a Body Segment
Hi, instead of tracking a high value, I was thinking about a maximize or minimize peak Q, Qdot, Udot, or output goal as there are C2-continuous approximations of max() like Log Sum Exp or other smooth maximum functions that get used in machine learning.
Though I don't think a custom goal like this will be trivial as copying any of the existing goals as I think you'll need to pass or collect an entire column of the states trajectory for calculating the cost, but if anyone can weigh in on if it would be feasible, it would be an interesting discussion.
Though I don't think a custom goal like this will be trivial as copying any of the existing goals as I think you'll need to pass or collect an entire column of the states trajectory for calculating the cost, but if anyone can weigh in on if it would be feasible, it would be an interesting discussion.