Skip to content

Commit 38f3511

Browse files
committed
feat: distinguish between profile target velocity and ground velocity
1 parent f3d464d commit 38f3511

File tree

3 files changed

+78
-32
lines changed

3 files changed

+78
-32
lines changed

include/OpenSpaceToolkit/Astrodynamics/Flight/Profile.hpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,19 @@ class Profile
9090

9191
enum class TargetType
9292
{
93-
GeocentricNadir, /// Negative of the position vector of the satellite in the ECI frame
94-
GeodeticNadir, /// Negative of the geodetic normal of the satellite in the ECI frame
95-
Trajectory, /// Points towards the provided trajectory, eg. Ground Station in ECEF
96-
TargetPosition, /// Points towards the provided target position
97-
TargetVelocity, /// Points along the target velocity vector
98-
Sun, /// The position of the Sun
99-
Moon, /// The position of the Moon
100-
VelocityECI, /// The velocity vector in the ECI frame
101-
VelocityECEF, /// The velocity vector in the ECEF frame
102-
OrbitalMomentum, /// The orbital momentum vector of the satellite in the ECI frame
103-
OrientationProfile, /// Points towards a profile of orientations in the ECI frame
104-
Custom, /// Custom target
93+
GeocentricNadir, /// Negative of the position vector of the satellite in the ECI frame
94+
GeodeticNadir, /// Negative of the geodetic normal of the satellite in the ECI frame
95+
Trajectory, /// Points towards the provided trajectory, eg. Ground Station in ECEF
96+
TargetPosition, /// Points towards the provided target position
97+
TargetVelocity, /// Points along the provided target's velocity vector
98+
TargetGroundVelocity, /// Points along the provided target's ground velocity vector (aka the scan direction)
99+
Sun, /// The position of the Sun
100+
Moon, /// The position of the Moon
101+
VelocityECI, /// The velocity vector in the ECI frame
102+
VelocityECEF, /// The velocity vector in the ECEF frame
103+
OrbitalMomentum, /// The orbital momentum vector of the satellite in the ECI frame
104+
OrientationProfile, /// Points towards a profile of orientations in the ECI frame
105+
Custom, /// Custom target
105106
};
106107

107108
/// @brief Represents a target for alignment or pointing purposes.
@@ -152,6 +153,17 @@ class Profile
152153
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection = false
153154
);
154155

156+
/// @brief Constructs a TrajectoryTarget object of type TargetGroundVelocity, pointing along the ground velocity
157+
/// vector (aka the scan direction). When choosing this as a clocking target, the resulting profile will be yaw
158+
/// compensated.
159+
///
160+
/// @param aTrajectory The trajectory to point towards.
161+
/// @param anAxis The axis of the target.
162+
/// @param isAntiDirection Whether the target is in the anti-direction.
163+
static TrajectoryTarget TargetGroundVelocity(
164+
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection = false
165+
);
166+
155167
ostk::astrodynamics::Trajectory trajectory; ///< The trajectory to point towards.
156168

157169
private:
@@ -392,6 +404,10 @@ class Profile
392404
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
393405
);
394406

407+
static Vector3d ComputeTargetGroundVelocityVector(
408+
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
409+
);
410+
395411
static Vector3d ComputeClockingAxisVector(const Vector3d& anAlignmentAxisVector, const Vector3d& aClockingVector);
396412

397413
static Quaternion ComputeBodyToECIQuaternion(

src/OpenSpaceToolkit/Astrodynamics/Flight/Profile.cpp

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,11 +60,11 @@ Profile::TrajectoryTarget Profile::TrajectoryTarget::TargetPosition(
6060
return TrajectoryTarget(TargetType::TargetPosition, aTrajectory, anAxis, isAntiDirection);
6161
}
6262

63-
Profile::TrajectoryTarget Profile::TrajectoryTarget::TargetVelocity(
63+
Profile::TrajectoryTarget Profile::TrajectoryTarget::TargetGroundVelocity(
6464
const ostk::astrodynamics::Trajectory& aTrajectory, const Axis& anAxis, const bool& isAntiDirection
6565
)
6666
{
67-
return TrajectoryTarget(TargetType::TargetVelocity, aTrajectory, anAxis, isAntiDirection);
67+
return TrajectoryTarget(TargetType::TargetGroundVelocity, aTrajectory, anAxis, isAntiDirection);
6868
}
6969

7070
Profile::TrajectoryTarget::TrajectoryTarget(
@@ -88,7 +88,7 @@ Profile::TrajectoryTarget::TrajectoryTarget(
8888
);
8989
}
9090

91-
if (aType != TargetType::TargetPosition && aType != TargetType::TargetVelocity)
91+
if (aType != TargetType::TargetPosition && aType != TargetType::TargetGroundVelocity)
9292
{
9393
throw ostk::core::error::runtime::Wrong("Target type");
9494
}
@@ -365,6 +365,15 @@ std::function<Quaternion(const State&)> Profile::AlignAndConstrain(
365365
return Profile::ComputeTargetVelocityVector(aState, targetVelocitySPtr->trajectory);
366366
};
367367
}
368+
case TargetType::TargetGroundVelocity:
369+
{
370+
const Shared<const TrajectoryTarget> targetVelocitySPtr =
371+
std::static_pointer_cast<const TrajectoryTarget>(aTargetSPtr);
372+
return [targetVelocitySPtr](const State& aState) -> Vector3d
373+
{
374+
return Profile::ComputeTargetGroundVelocityVector(aState, targetVelocitySPtr->trajectory);
375+
};
376+
}
368377
case TargetType::Sun:
369378
return [](const State& aState)
370379
{
@@ -477,6 +486,16 @@ Vector3d Profile::ComputeTargetDirectionVector(const State& aState, const ostk::
477486
}
478487

479488
Vector3d Profile::ComputeTargetVelocityVector(const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory)
489+
{
490+
const Vector3d targetVelocityCoordinates =
491+
aTrajectory.getStateAt(aState.accessInstant()).inFrame(DEFAULT_ECI_FRAME).getVelocity().accessCoordinates();
492+
493+
return targetVelocityCoordinates.normalized();
494+
}
495+
496+
Vector3d Profile::ComputeTargetGroundVelocityVector(
497+
const State& aState, const ostk::astrodynamics::Trajectory& aTrajectory
498+
)
480499
{
481500
const Instant& instant = aState.accessInstant();
482501

test/OpenSpaceToolkit/Astrodynamics/Flight/Profile.test.cpp

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,12 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, GetStatesAt)
246246
}
247247

248248
{
249-
EXPECT_ANY_THROW(Profile::Undefined().getStatesAt(
250-
{Instant::DateTime(DateTime(2018, 1, 1, 0, 0, 0), Scale::UTC),
251-
Instant::DateTime(DateTime(2018, 1, 1, 0, 0, 1), Scale::UTC)}
252-
));
249+
EXPECT_ANY_THROW(
250+
Profile::Undefined().getStatesAt(
251+
{Instant::DateTime(DateTime(2018, 1, 1, 0, 0, 0), Scale::UTC),
252+
Instant::DateTime(DateTime(2018, 1, 1, 0, 0, 1), Scale::UTC)}
253+
)
254+
);
253255
}
254256
}
255257

@@ -306,9 +308,12 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, InertialPointing)
306308

307309
// Reference data setup
308310

309-
const File referenceDataFile =
310-
File::Path(Path::Parse("/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/InertialPointing/Satellite "
311-
"t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv"));
311+
const File referenceDataFile = File::Path(
312+
Path::Parse(
313+
"/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/InertialPointing/Satellite "
314+
"t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv"
315+
)
316+
);
312317

313318
const Table referenceData = Table::Load(referenceDataFile, Table::Format::CSV, true);
314319

@@ -421,8 +426,10 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, LocalOrbitalFramePointing_
421426
// Reference data setup
422427

423428
const File referenceDataFile = File::Path(
424-
Path::Parse("/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/LocalOrbitalFramePointing/VVLH/"
425-
"Satellite_1 t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv")
429+
Path::Parse(
430+
"/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/LocalOrbitalFramePointing/VVLH/"
431+
"Satellite_1 t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv"
432+
)
426433
);
427434

428435
const Table referenceData = Table::Load(referenceDataFile, Table::Format::CSV, true);
@@ -532,8 +539,10 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, LocalOrbitalFramePointing_
532539
// Reference data setup
533540

534541
const File referenceDataFile = File::Path(
535-
Path::Parse("/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/LocalOrbitalFramePointing/VVLH/"
536-
"Satellite_2 t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv")
542+
Path::Parse(
543+
"/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/LocalOrbitalFramePointing/VVLH/"
544+
"Satellite_2 t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv"
545+
)
537546
);
538547

539548
const Table referenceData = Table::Load(referenceDataFile, Table::Format::CSV, true);
@@ -643,8 +652,10 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, LocalOrbitalFramePointing_
643652
// Reference data setup
644653

645654
const File referenceDataFile = File::Path(
646-
Path::Parse("/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/LocalOrbitalFramePointing/VVLH/"
647-
"Satellite_3 t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv")
655+
Path::Parse(
656+
"/app/test/OpenSpaceToolkit/Astrodynamics/Flight/Profile/LocalOrbitalFramePointing/VVLH/"
657+
"Satellite_3 t_UTC x_GCRF v_GCRF q_B_GCRF w_B_GCRF_in_GCRF.csv"
658+
)
648659
);
649660

650661
const Table referenceData = Table::Load(referenceDataFile, Table::Format::CSV, true);
@@ -847,7 +858,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, TrajectoryTarget)
847858
ostk::core::error::runtime::Undefined
848859
);
849860
EXPECT_THROW(
850-
Profile::TrajectoryTarget::TargetVelocity(Trajectory::Undefined(), Profile::Axis::X),
861+
Profile::TrajectoryTarget::TargetGroundVelocity(Trajectory::Undefined(), Profile::Axis::X),
851862
ostk::core::error::runtime::Undefined
852863
);
853864
}
@@ -860,8 +871,8 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, TrajectoryTarget)
860871
// Testing static factory methods
861872
EXPECT_NO_THROW(Profile::TrajectoryTarget::TargetPosition(trajectory, Profile::Axis::X));
862873
EXPECT_NO_THROW(Profile::TrajectoryTarget::TargetPosition(trajectory, Profile::Axis::X, true));
863-
EXPECT_NO_THROW(Profile::TrajectoryTarget::TargetVelocity(trajectory, Profile::Axis::X));
864-
EXPECT_NO_THROW(Profile::TrajectoryTarget::TargetVelocity(trajectory, Profile::Axis::X, true));
874+
EXPECT_NO_THROW(Profile::TrajectoryTarget::TargetGroundVelocity(trajectory, Profile::Axis::X));
875+
EXPECT_NO_THROW(Profile::TrajectoryTarget::TargetGroundVelocity(trajectory, Profile::Axis::X, true));
865876
}
866877
}
867878

@@ -939,7 +950,7 @@ TEST_F(OpenSpaceToolkit_Astrodynamics_Flight_Profile, YawCompensation)
939950
Profile::TrajectoryTarget::TargetPosition(trajectory, Profile::Axis::Z)
940951
),
941952
std::make_shared<const Profile::TrajectoryTarget>(
942-
Profile::TrajectoryTarget::TargetVelocity(trajectory, Profile::Axis::X)
953+
Profile::TrajectoryTarget::TargetGroundVelocity(trajectory, Profile::Axis::X)
943954
)
944955
);
945956

0 commit comments

Comments
 (0)