The difference in the usage of CelestialBodyPointed between version 13.0 and version 12.0 of Orekit

Hello everyone,

I want to implement an attitude mode where the spacecraft’s body axis points toward another spacecraft. I had already achieved this in version 12.0 using attitudes.CelestialBodyPointed. The usage was simple because the second parameter of the CelestialBodyPointed constructor was a PVCoordinatesProvider. I instantiated a KeplerianPropagator and passed it as the second argument to the CelestialBodyPointed constructor, which worked perfectly for my needs.

However, after updating Orekit to version 13.0, the second parameter type of the CelestialBodyPointed constructor has changed to ExtendedPositionProvider, and this type does not allow the use of KeplerianPropagator as a substitute. As a result, I’ve encountered difficulties.

If anyone has faced this issue and found a solution, please help me out by explaining how to resolve it. Thank you all!

You can probably use AlignedAndConstrained with a custom TargetProvider.
Here is one I implemented for a project I am working on. I will certainly contribute it to Orekit, but did not do so yet as it is clearly limited to one field type only (which did fit my needs):

public class SatelliteTarget implements TargetProvider
{

    /** Propagator providing target satellite position. */
    private final Propagator targetPropagator;

    /**
     * Simple constructor.
     * @param targetPropagator propagator providing target satellite position
     */
    public SatelliteTarget(final Propagator targetPropagator)
    {
        this.targetPropagator = targetPropagator;
    }

    @Override
    public <T extends CalculusFieldElement<T>> FieldVector3D<T> getTargetDirection(final ExtendedPositionProvider sun,
                                                                                   final OneAxisEllipsoid earth,
                                                                                   final TimeStampedFieldPVCoordinates<T> pv,
                                                                                   final Frame frame)
    {

        if (pv.getDate().getField() != UnivariateDerivative2Field.getInstance())
        {
            // we expect only second order univariate derivatives here
            throw new OrekitException(OrekitMessages.OUT_OF_RANGE_DERIVATION_ORDER);
        }

        // compute Cartesian coordinates of the target satellite
        final PVCoordinates                             targetPV  = targetPropagator.getPVCoordinates(pv.getDate().toAbsoluteDate(), frame);
        final FieldPVCoordinates<UnivariateDerivative2> targetPV2 = targetPV.toUnivariateDerivative2PV();

        // convert to a direction as seen from the current satellite
        @SuppressWarnings("unchecked")
        final FieldPVCoordinates<UnivariateDerivative2> pv2 = (FieldPVCoordinates<UnivariateDerivative2>) pv;
        final FieldVector3D<UnivariateDerivative2> direction2 = pv2.getPosition().subtract(targetPV2.getPosition()).normalize();
        @SuppressWarnings("unchecked")
        final FieldVector3D<T> direction = (FieldVector3D<T>) direction2;

        return direction;

    }

}

That’s great, thank you!