ompl icon indicating copy to clipboard operation
ompl copied to clipboard

Trouble benchmarking with custom optimization objetives

Open elishafer opened this issue 5 years ago • 1 comments

I tried to create a benchmark in Python with a custom OptimizationObjective e.g.:

class DummyObjective(ob.OptimizationObjective):
    def __init__(self, si):
        super(DummyObjective, self).__init__(si)
        self.si_ = si

    def motionCost(self, s1, s2):
        return ob.Cost(self.si_.distance(s1, s2))

I then added it using simple setup: ss.setOptimizationObjective(DummyObjective(si)) but I get a TypeError: 'NoneType' object is not callable error when running the benchmark. The optimisation works when doing path planning without benchmarking. Also, using regular pathlength for the optimization objective works as does the clearance objective mentioned in the demos:

class ClearanceObjective(ob.StateCostIntegralObjective):
    def __init__(self, si):
        super(ClearanceObjective, self).__init__(si, True)
        self.si_ = si

    def stateCost(self, s):
        return ob.Cost(1 / (self.si_.getStateValidityChecker().clearance(s) +
                            sys.float_info.min))

Any idea what I'm doing wrong? Thanks!

elishafer avatar Jan 10 '21 09:01 elishafer

stateCost needs to be implemented in your optimization objective.

zkingston avatar Feb 16 '23 01:02 zkingston