loco-3d / crocoddyl

Crocoddyl is an optimal control library for robot control under contact sequence. Its solver is based on various efficient Differential Dynamic Programming (DDP)-like algorithms
BSD 3-Clause "New" or "Revised" License
855 stars 174 forks source link

Update shooting problem for scrolling optimization #1233

Closed lrchit closed 8 months ago

lrchit commented 8 months ago

Hello,

I'm trying to do nmpc things on quadruped robot with crocoddyl. I compute nmpc on 100 Hz, covering 50 horizons, but at every step I must update the problem for scrolling optimization. For instance, at the first step the shooting nodes are from 0 to 50, but at the next step the nodes should be from 1 to 51. I tried updateNode() and updateModel() but both of them are a little bit slow -- the solver costs 10 ms, but updating the problem costs 20ms. It also cost much time to create a new problem. I wonder how can I update the shooting problem for scrolling optimization. Could anyone tell me how to get a quick update?

Thanks in advance! Andy

cmastalli commented 8 months ago

Hi @lrchit!

updateNode doesn't allocate data or copy the model and data objects. It is expected to be very efficient.

Could you share a bench code where we can reproduce the reported computation time?

lrchit commented 8 months ago

Hi @lrchit!

updateNode doesn't allocate data or copy the model and data objects. It is expected to be very efficient.

Could you share a bench code where we can reproduce the reported computation time?

Hi, Thanks for your attention. I said something wrong that I didn't use updateNode, because I didn't know if I should createData every step. Today I notice that boost::shared_ptr<ActionDataAbstract> data is a pointer and there's no need to createData every time. So I tried createData at first and use updateNode every step and it works well! Thanks again.

cmastalli commented 8 months ago

Indeed, data allocation is something you need to avoid.

I'll close this issue as seems sorted out.