Skip to content

Ensuring Consistent State Space Type in CForestStateSpaceWrapper #1290

@Everest-Zhao

Description

@Everest-Zhao

I noticed a potential issue with CForestStateSpaceWrapper. This class inherits from StateSpace but does not explicitly assign an initial value to type_, leaving it as the default value STATE_SPACE_UNKNOWN.

A possible error I discovered is in PathLengthDirectInfSampler.cpp (lines 96–117), where values are set based on different state space types:

if (!InformedSampler::space_->isCompound())
{
    if (InformedSampler::space_->getType() == STATE_SPACE_REAL_VECTOR)
    {
        // R^n, this is easy
        informedIdx_ = 0u;
        uninformedIdx_ = 0u;
    }
    else if (InformedSampler::space_->getType() == STATE_SPACE_UNKNOWN)
    {
        // Unknown, this is annoying. I hope the user knows what they're doing
        OMPL_WARN("PathLengthDirectInfSampler: Treating the StateSpace of type \"STATE_SPACE_UNKNOWN\" as "
                  "type \"STATE_SPACE_REAL_VECTOR\".");
        informedIdx_ = 0u;
        uninformedIdx_ = 0u;
    }
    else
    {
        throw Exception("PathLengthDirectInfSampler only supports Unknown, RealVector, SE2, and SE3 "
                        "StateSpaces.");
    }
}

To address this, I believe the state space type of CForestStateSpaceWrapper should be consistent with the type of the StateSpace provided during its construction. For example:

CForestStateSpaceWrapper(geometric::CForest *cforest, base::StateSpace *space)
    : cforest_(cforest), space_(space), planner_(nullptr)
{
    this->type_ = space->getType();
    setName(space->getName() + "CForestWrapper");
}

This approach seems more reasonable and ensures consistency between the wrapper and the underlying StateSpace.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions