Add other constraint in OMPL task solver

Typically: "How do I... ", "How can I... " questions
Post Reply
cxt
Posts: 16
Joined: 08 Sep 2020, 04:12

Add other constraint in OMPL task solver

Post by cxt »

Hi,

My problem requires the path solved by motion planning to satisfy position and orientation constraints. I went through OMPL API and an example code of motion planning, it seems I need to write my custom isStateValidCallback function to overwrite the default one that only does collision checking. My question is, if I overwrite that, do I need to explicitly call collsiion checking along with constraint checking in this callback function? If so, which API should I use?

coppelia
Site Admin
Posts: 10336
Joined: 14 Dec 2012, 00:25

Re: Add other constraint in OMPL task solver

Post by coppelia »

Hello,

if you set-up a custom state validation routine with simOMPL.setStateValidationCallback, then you can do anything you want inside of the callback function: you can check for collision, you can check for joint angles, etc. The only important thing is to return a boolean value: if false or nil, the state is invalid, otherwise it is valid. So e.g. with:

Code: Select all

function stateValidation(state)
    return true
end
all states would be valid.

See also the example scene in scenes/pathPlanning/state_validation_callback.ttt

Cheers

fferri
Posts: 1193
Joined: 09 Sep 2013, 19:28

Re: Add other constraint in OMPL task solver

Post by fferri »

cxt wrote: 02 Oct 2021, 01:55 if I overwrite that, do I need to explicitly call collsiion checking along with constraint checking in this callback function?
Yes.

The default state validity checking uses sim.checkCollision to determine validity of a state.

If a custom state validity checking function is set, the default state validity checking will not be used, therefore if you also want to check for collision, you need to replicate that behavior, by using simOMPL.readState, simOMPL.writeState, sim.checkCollision, etc...

Post Reply