Support CCSDS Maneuver Message format
Conversion of https://gitlab.com/nyx-space/nyx/-/issues/227 with ChatGPT.
High level description
The CCSDS (Consultative Committee for Space Data Systems) Maneuver Message is a standard format for transmitting commands to spacecraft to perform maneuvers. The CCSDS Maneuver Message specifies the parameters that define a spacecraft maneuver, such as the spacecraft's state vector, the maneuver delta-V vector, and the maneuver time.
This issue aims to add support for the CCSDS Maneuver Message format to Nyx, allowing users to output spacecraft maneuvers in this standard format for use in spacecraft mission design and orbit determination.
Requirements
To support the CCSDS Maneuver Message format in Nyx, the following requirements must be met:
- Implement a new
ManeuverMessagestructure that represents a spacecraft maneuver using the CCSDS Maneuver Message format. - Update the
Optimizerstructure to allow users to output spacecraft maneuvers asManeuverMessagevalues. - Provide examples of how Nyx can be used to design missions and optimize maneuvers using the CCSDS Maneuver Message format.
Test plans
To test the CCSDS Maneuver Message format in Nyx, the following steps can be taken:
- Define a set of known spacecraft maneuvers with known parameters, such as state vectors and delta-V vectors.
- Use the
Optimizerin Nyx to design missions and optimize maneuvers using the known spacecraft maneuvers. - Compare the output
ManeuverMessagevalues to the known spacecraft maneuvers to verify their accuracy. - Test the ability to output
ManeuverMessagevalues in different scenarios, such as different spacecraft states and different maneuver objectives.
Design
API definition
The ManeuverMessage structure defines a spacecraft maneuver in the CCSDS Maneuver Message format. It contains fields for the spacecraft's state vector, the maneuver delta-V vector, and the time at which the maneuver should be performed. It also provides accessor methods for the spacecraft's position, velocity, attitude, mass, and delta-V magnitude at the time of the maneuver.
#[derive(Debug)]
pub struct ManeuverMessage {
/// The spacecraft state vector at the time of the maneuver
pub state: State,
/// The maneuver delta-V vector
pub delta_v: Vector3,
/// The time at which the maneuver should be performed
pub time: Instant, // Human: change to hifitime Epoch
}
impl ManeuverMessage {
/// Returns the spacecraft's position at the time of the maneuver
pub fn position(&self) -> Vector3 {
self.state.position
}
/// Returns the spacecraft's velocity at the time of the maneuver
pub fn velocity(&self) -> Vector3 {
self.state.velocity
}
/// Returns the spacecraft's attitude at the time of the maneuver
pub fn attitude(&self) -> UnitQuaternion {
self.state.attitude
}
/// Returns the spacecraft's mass at the time of the maneuver
pub fn mass(&self) -> f64 {
self.state.mass
}
/// Returns the spacecraft's delta-V magnitude at the time of the maneuver
pub fn delta_v_magnitude(&self) -> f64 {
self.delta_v.magnitude()
}
}
High level architecture
Document, discuss, and optionally upload design diagram into this section.
Detailed design
To support the CCSDS Maneuver Message format in Nyx, the following changes will be made to the Nyx APIs:
- A new
ManeuverMessagestructure will be implemented to represent a spacecraft maneuver using the CCSDS Maneuver Message format. TheManeuverMessagestructure will contain fields for the spacecraft's state vector, the maneuver delta-V vector, and the maneuver time, as specified by the CCSDS Maneuver Message format. - The
Optimizerstructure will be updated to allow users to output spacecraft maneuvers asManeuverMessagevalues. TheOptimizerwill provide a new function,to_maneuver_message(), that will return aManeuverMessagevalue for the optimized spacecraft maneuver. - Example code will be provided to demonstrate how Nyx can be used to design missions and optimize maneuvers using the CCSDS Maneuver Message format.
Example code
The following example code demonstrates how Nyx can be used to design a mission and optimize a maneuver using the CCSDS Maneuver Message format.
use nyx::{Optimizer, Objective, Event, StateParameter, Duration};
use nyx::maneuver_message::ManeuverMessage;
// Define the initial spacecraft state
let initial_state = State {
// ...
};
// Define the target event and duration
let target = Event {
parameter: StateParameter::Altitude,
desired_value: 500.0,
epoch_precision: Unit::Seconds(10.0),
value_precision: 0.1,
};
let duration = Duration::Hours(1.0);
// Define the targeting objective
let objective = Objective {
target: Either::Left(target),
duration,
};
// Create the optimizer
let mut optimizer = Optimizer::new(initial_state);
// Optimize the spacecraft maneuver to achieve the target event
let result = optimizer.optimize(&[objective]);
// Check if a solution was found
if let Some(solution) = result {
// Output the optimized spacecraft maneuver as a CCSDS Maneuver Message
let maneuver_message = solution.get_maneuver_message();
println!("CCSDS Maneuver Message: {:?}", maneuver_message);
} else {
println!("Unable to find a solution");
}