Skip to content

feat: distinguish between profile target velocity and ground velocity #561

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Flight_Profile(pybind11::module& aMo
.value("Trajectory", Profile::TargetType::Trajectory, "Trajectory") // Deprecated in favor of TargetPosition
.value("TargetPosition", Profile::TargetType::TargetPosition, "Target position")
.value("TargetVelocity", Profile::TargetType::TargetVelocity, "Target velocity")
.value(
"TargetSlidingGroundVelocity",
Profile::TargetType::TargetSlidingGroundVelocity,
"Target sliding ground velocity"
)
.value("Sun", Profile::TargetType::Sun, "Sun")
.value("Moon", Profile::TargetType::Moon, "Moon")
.value("VelocityECI", Profile::TargetType::VelocityECI, "Velocity in ECI")
Expand Down Expand Up @@ -138,7 +143,18 @@ inline void OpenSpaceToolkitAstrodynamicsPy_Flight_Profile(pybind11::module& aMo
"target_velocity",
&Profile::TrajectoryTarget::TargetVelocity,
R"doc(
Create a target, which produces a vector pointing along the target velocity.
Create a target, which produces a vector pointing along the scan direction.
)doc",
arg("trajectory"),
arg("axis"),
arg("anti_direction") = false
)
.def_static(
"target_sliding_ground_velocity",
&Profile::TrajectoryTarget::TargetSlidingGroundVelocity,
R"doc(
Create a target, which produces a vector pointing along the ground velocity vector (aka the scan direction of the point sliding across the ground).
This will compensate for the rotation of the referenced celestial body.
)doc",
arg("trajectory"),
arg("axis"),
Expand Down
51 changes: 34 additions & 17 deletions include/OpenSpaceToolkit/Astrodynamics/Flight/Profile.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,20 @@ class Profile

enum class TargetType
{
GeocentricNadir, /// Negative of the position vector of the satellite in the ECI frame
GeodeticNadir, /// Negative of the geodetic normal of the satellite in the ECI frame
Trajectory, /// Points towards the provided trajectory, eg. Ground Station in ECEF
TargetPosition, /// Points towards the provided target position
TargetVelocity, /// Points along the target velocity vector
Sun, /// The position of the Sun
Moon, /// The position of the Moon
VelocityECI, /// The velocity vector in the ECI frame
VelocityECEF, /// The velocity vector in the ECEF frame
OrbitalMomentum, /// The orbital momentum vector of the satellite in the ECI frame
OrientationProfile, /// Points towards a profile of orientations in the ECI frame
Custom, /// Custom target
GeocentricNadir, /// Negative of the position vector of the satellite in the ECI frame
GeodeticNadir, /// Negative of the geodetic normal of the satellite in the ECI frame
Trajectory, /// Points towards the provided trajectory, eg. Ground Station in ECEF
TargetPosition, /// Points towards the provided target position
TargetVelocity, /// Points along the provided target's velocity vector
TargetSlidingGroundVelocity, /// Points along the provided target's ground velocity vector (aka the scan
/// direction of the point sliding across the ground)
Sun, /// The position of the Sun
Moon, /// The position of the Moon
VelocityECI, /// The velocity vector in the ECI frame
VelocityECEF, /// The velocity vector in the ECEF frame
OrbitalMomentum, /// The orbital momentum vector of the satellite in the ECI frame
OrientationProfile, /// Points towards a profile of orientations in the ECI frame
Custom, /// Custom target
};

/// @brief Represents a target for alignment or pointing purposes.
Expand Down Expand Up @@ -143,7 +145,8 @@ class Profile
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection = false
);

/// @brief Constructs a TrajectoryTarget object of type TargetVelocity, pointing along the scan direction.
/// @brief Constructs a TrajectoryTarget object of type TargetVelocity, pointing along the scan direction. When
/// choosing this as a clocking target, the resulting profile will not be yaw compensated.
///
/// @param aTrajectory The trajectory to point towards.
/// @param anAxis The axis of the target.
Expand All @@ -152,6 +155,17 @@ class Profile
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection = false
);

/// @brief Constructs a TrajectoryTarget object of type TargetSlidingGroundVelocity, pointing along the ground
/// velocity vector (aka the scan direction of the point sliding across the ground). This will compensate for
/// the rotation of the referenced celestial body.
///
/// @param aTrajectory The trajectory to point towards.
/// @param anAxis The axis of the target.
/// @param isAntiDirection Whether the target is in the anti-direction.
static TrajectoryTarget TargetSlidingGroundVelocity(
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection = false
);

ostk::astrodynamics::Trajectory trajectory; ///< The trajectory to point towards.

private:
Expand Down Expand Up @@ -380,6 +394,13 @@ class Profile
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
);

static Vector3d ComputeTargetVelocityVector(
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
);
static Vector3d ComputeTargetSlidingGroundVelocityVector(
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
);

static Vector3d ComputeCelestialDirectionVector(const State& aState, const Celestial& aCelestial);

static Vector3d ComputeVelocityDirectionVector_ECI(const State& aState);
Expand All @@ -388,10 +409,6 @@ class Profile

static Vector3d ComputeOrbitalMomentumDirectionVector(const State& aState);

static Vector3d ComputeTargetVelocityVector(
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
);

static Vector3d ComputeClockingAxisVector(const Vector3d& anAlignmentAxisVector, const Vector3d& aClockingVector);

static Quaternion ComputeBodyToECIQuaternion(
Expand Down
44 changes: 39 additions & 5 deletions src/OpenSpaceToolkit/Astrodynamics/Flight/Profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,13 @@
return TrajectoryTarget(TargetType::TargetVelocity, aTrajectory, anAxis, isAntiDirection);
}

Profile::TrajectoryTarget Profile::TrajectoryTarget::TargetSlidingGroundVelocity(
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection
)
{
return TrajectoryTarget(TargetType::TargetSlidingGroundVelocity, aTrajectory, anAxis, isAntiDirection);
}

Profile::TrajectoryTarget::TrajectoryTarget(
const TargetType& aType,
const ostk::astrodynamics::Trajectory& aTrajectory,
Expand All @@ -87,7 +94,8 @@
);
}

if (aType != TargetType::TargetPosition && aType != TargetType::TargetVelocity)
if (aType != TargetType::TargetPosition && aType != TargetType::TargetVelocity &&
aType != TargetType::TargetSlidingGroundVelocity)
{
throw ostk::core::error::runtime::Wrong("Target type");
}
Expand Down Expand Up @@ -364,6 +372,15 @@
return Profile::ComputeTargetVelocityVector(aState, targetVelocitySPtr->trajectory);
};
}
case TargetType::TargetSlidingGroundVelocity:
{
const Shared<const TrajectoryTarget> targetVelocitySPtr =
std::static_pointer_cast<const TrajectoryTarget>(aTargetSPtr);
return [targetVelocitySPtr](const State& aState) -> Vector3d
{
return Profile::ComputeTargetSlidingGroundVelocityVector(aState, targetVelocitySPtr->trajectory);
};
}
case TargetType::Sun:
return [](const State& aState)
{
Expand Down Expand Up @@ -477,23 +494,40 @@
}

Vector3d Profile::ComputeTargetVelocityVector(const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory)
{
const Vector3d targetVelocityCoordinates =
aTrajectory.getStateAt(aState.accessInstant()).inFrame(DEFAULT_PROFILE_FRAME).getVelocity().accessCoordinates();

if (targetVelocityCoordinates.isZero())
{
throw ostk::core::error::RuntimeError(
"Cannot compute a Target Velocity Vector if the target's velocity is zero."
);

Check warning on line 505 in src/OpenSpaceToolkit/Astrodynamics/Flight/Profile.cpp

View check run for this annotation

Codecov / codecov/patch

src/OpenSpaceToolkit/Astrodynamics/Flight/Profile.cpp#L505

Added line #L505 was not covered by tests
}
return targetVelocityCoordinates.normalized();
}

Vector3d Profile::ComputeTargetSlidingGroundVelocityVector(
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
)
{
const Instant& instant = aState.accessInstant();

const Vector3d slidingTargetGroundVelocityCoordinates =
const Vector3d targetSlidingGroundVelocityCoordinates =
aTrajectory.getStateAt(instant).inFrame(Frame::ITRF()).getVelocity().accessCoordinates();

if (slidingTargetGroundVelocityCoordinates.isZero())
if (targetSlidingGroundVelocityCoordinates.isZero())
{
throw ostk::core::error::RuntimeError(
"Cannot compute a Target Velocity Vector if the target's sliding velocity is zero."
"Cannot compute a Target Sliding Ground Velocity Vector if the target's sliding velocity with respect to "
"the ground is zero."
);
}

const Transform ITRF_GCRF_transform = Frame::ITRF()->getTransformTo(DEFAULT_PROFILE_FRAME, instant);

const Vector3d slidingTargetGroundVelocityCoordinatesRotated =
ITRF_GCRF_transform.applyToVector(slidingTargetGroundVelocityCoordinates);
ITRF_GCRF_transform.applyToVector(targetSlidingGroundVelocityCoordinates);

return slidingTargetGroundVelocityCoordinatesRotated.normalized();
}
Expand Down
Loading