Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
OCP Croco Class #112
base: topic/humble-devel/refactor
Are you sure you want to change the base?
OCP Croco Class #112
Changes from 11 commits
2b74b10
60648fc
3d36d16
0820ea7
16fbafe
6ff4507
1da7779
0105d0c
4ddeea4
b2eac48
4f07f49
61beafa
5d0ced3
6be9c9f
bf1dde7
4c42f41
eab8f12
894fce4
09c47cc
cf7991f
a55807d
f7db9b6
92212d2
0e8d145
95ab7c7
ef8bd36
5cda790
6e54b6e
58b8dc7
3faa492
4e2373c
9047baa
ebb28b7
90afd0f
1fb5f38
c544c12
e422536
fa3da6e
5c8a53e
038cd0f
8ce22ad
156afd8
f6c8efb
982f976
31c06ff
e011080
bc1f31d
255c1f0
417d9bb
bafd67c
54ddd9b
adb3ced
861f7c2
db440c7
b2f99bb
ee4181c
841493e
402968b
d6ca98b
55c3095
dcf4812
b8eb8ab
72e2185
b6266d0
303dd30
0dfe450
6b731ca
7c703d6
25d8344
d2b9107
ad39d40
2885b0a
8083c11
c1f6126
0cc5936
9e5c374
d9e49cc
88d2449
2aa81eb
88f572d
c7cb95c
91bf33c
b52e01d
e29276f
e3ba9e6
a097d30
3ba81d4
57b2f36
ce26d70
b2afd0f
1c8a1e3
70a73ee
393ff30
406a689
12d17ef
80062e6
720cf23
f5fed68
ea73d2e
620f4b0
2c55b75
a91e554
294f5b9
4a7cedd
d805ea4
d53b0f6
086bcca
3e59282
ca1066b
488ab70
b3c121b
a3ee5c5
6fcf107
3ddf226
d6caca3
faf187e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO
OCPParamsCrocoBase
should be simply arguments of the__init__
function. In C++ it's required due to registers and stuff, but python doesn't careThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i believe that having a data class is better for readability / organisation purpose, and so that you don't have gazillion of stuff in the init of the class
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But most of them can be passed as defaults. And this is a common pattern in python libraries. Just look at how many parameters matplotlib function have
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be obtained from
SolverBase.problem.T + 1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we don't have access to it before we set the solver so I guess it's fine this way ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. But if you set up the problem in the
__init__
you will always have it set upThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no need for
@abstractmethd
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In theory this can be obtained from
SolverBase.problem.RunningModels[0].dt
, but this makes an assumption that the fist running model is of a typeIntegratedActionModelAbstract
and all running models have the samedt
. Other option I would suggest is to storedt
as a class parameter and returnself._dt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but we can obtain it from the params class, and for clarity's sake, i believe that having many methods returning the same value may be problematic at some point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is wrong.
The WeightedTrajectoryPoints is meant as references not initial state.
x0 is coming from the robot sensors while WeightedTrajectoryPoints comes from the planner (or higher entity).
I would remove this method all together.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second removing this method
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again the ocp don't need this is comes in from the warmstart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
snake_case: "TrajectoryPoint" -> "trajectory_point" or "traj_point" or "t_point" etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
little preference for "trajectory_point"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
comes form the warmsart.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we initial that earlier? And not in the online part?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should generally be a part of
__init__
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general, I wonder if this is reasonable (in terms of time) to create croco objects (running/terminal costs, Action models etc.) from scratch every time we solve? It's simpler than going through through the croco ocp structure to only but might be a bit slow.
I just checked on a personal codebase a similar function and got:
T = 20 -> 0.7 ms
T = 40 -> 1.5 ms
T = 60 -> 2.7 ms
T = 80 -> 3.8 ms
T = 100 -> 4.5 ms
So it seems that the _state/_actuation creation is negligeable (I'd still put it in
__init__
or asetup
function) compared to the running cost creation.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the test @MedericFourmy! But yeah, i believe we can put as much as possible in the init
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here you should assume an abstract API that fills the
self._runningModelList
and the name of the variable is wrong. This is google standard not pep8.Hence:
and later on:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that the
CostModelSum::addCost
API take a vector of weights as its third input:https://github.com/loco-3d/crocoddyl/blob/da92f67394c07c987458a8cb24bc0e33edd64227/include/crocoddyl/core/costs/cost-sum.hxx#L29
For weights regularization, you can define a
CostModelResidual
with anActivationModelWeightedQuad
, see here or here.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you! I was doing it blindly here tbh
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same story as for the runnning models. All Python variables are
snake_case
.Plus you should define a function that fills this list:
and then use it in the solve function again:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we assume that you and Theo are going to use the
mim_solvers
all the time?I guess yes due to constraints...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we can have a flag in the ocp param maybe to indicate which solver use? but it might be too verbose, we could only use mim solver & csqp, which is a sqp solver when there's no constraints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would keep it simple and set the mim_solvers as the default for everyone.
If the performance are similar I would take the most generic solver and impose this one...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be a parameter?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is all that this class should implement. Nothing more. Solve, and pass it to our objects. The rest should be a separate function that creates OCP and shooting problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function should not return anything just like the
OCPBase
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Follow the remark on the "T" name above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should go with a
RobotModel
object that goes into the robot_model class.We should use the srdf of the robot for this maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
srdf would be a hassle, but we could discuss it in a separate PR. For now, i simply put the armature as a property.