update source code
Signed-off-by: Douglas Schilling Landgraf <dougsland@redhat.com>
This commit is contained in:
parent
3c13d71bb5
commit
b03ffe61d9
|
@ -0,0 +1,35 @@
|
|||
# setup.py
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name='rocket_launcher',
|
||||
version='0.1.0',
|
||||
description='A rocket launch simulation package.',
|
||||
author='Douglas Schilling Landgraf, Leonardo Rossetti, Dan Walsh',
|
||||
author_email='dougsland@redhat.com, lrossett@redhat.com, dwalsh@redhat.com',
|
||||
license='Apache License 2.0',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'rclpy',
|
||||
'std_msgs',
|
||||
],
|
||||
classifiers=[
|
||||
'Programming Language :: Python :: 3',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
'Operating System :: OS Independent',
|
||||
],
|
||||
python_requires='>=3.6',
|
||||
)
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
*.egg-info
|
||||
build/
|
|
@ -0,0 +1,40 @@
|
|||
```
|
||||
python -m venv ~/pythonvenv/spacegradelinux
|
||||
source ~/pythonvenv/spacegradelinux
|
||||
|
||||
git clone https://github.com/containers/space-grade-linux.git
|
||||
cd space-grade-linux/APIs/python/Rocket_Lauch_Simulator
|
||||
pip install .
|
||||
cd examples
|
||||
./nasa
|
||||
```
|
||||
|
||||
```
|
||||
Starting NASA Rocket Launch Simulation...
|
||||
🚀 Starting launch sequence for NASA Mars Mission with payload: Curiosity Rover 🚀
|
||||
|
||||
--- Stage: Pre-Launch Preparations ---
|
||||
|
||||
--- Stage: Ignition and Liftoff ---
|
||||
|
||||
--- Stage: Ascent Stage ---
|
||||
|
||||
--- Stage: Stage Separation ---
|
||||
|
||||
--- Stage: Fairing Separation ---
|
||||
|
||||
--- Stage: Orbital Insertion or Payload Deployment ---
|
||||
|
||||
--- Stage: Stage Reentry and Recovery ---
|
||||
|
||||
--- Stage: Post-Launch Operations ---
|
||||
🎉 Launch sequence completed successfully! 🎉
|
||||
|
||||
Executing Curiosity Rover Mission Operations...
|
||||
🪐 Curiosity rover entering Martian atmosphere...
|
||||
🪂 Deploying parachute for descent...
|
||||
🛸 Initiating sky-crane maneuver...
|
||||
🪨 Curiosity rover has landed safely on Mars!
|
||||
🛰️ Starting surface operations and data collection.
|
||||
|
||||
```
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
Module utilizing Blue Origin-specific operations for the RocketLaunch simulation.
|
||||
"""
|
||||
|
||||
from rocket_launcher import RocketLaunch
|
||||
from rocket_launcher import blue_origin
|
||||
|
||||
def main():
|
||||
"""
|
||||
Simulate a Blue Origin rocket launch with payload deployment and return operations.
|
||||
"""
|
||||
rocket = RocketLaunch("Blue Origin New Shepard", "Research Payload", "blue_origin")
|
||||
|
||||
print("\nStarting Blue Origin Rocket Launch Simulation...")
|
||||
rocket.simulate_launch()
|
||||
|
||||
print("\nExecuting Blue Origin Precision Payload Deployment...")
|
||||
blue_origin.blue_origin_payload_deployment(rocket)
|
||||
|
||||
print("\nExecuting Blue Origin Return and Landing...")
|
||||
blue_origin.blue_origin_return_and_landing(rocket)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,37 @@
|
|||
#!/usr/bin/env python3
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
Module utilizing Boeing-specific operations for the RocketLaunch simulation.
|
||||
"""
|
||||
|
||||
from rocket_launcher import RocketLaunch
|
||||
from rocket_launcher import boeing
|
||||
|
||||
def main():
|
||||
"""
|
||||
Simulate a Boeing rocket launch with payload deployment and return operations.
|
||||
"""
|
||||
rocket = RocketLaunch("Boeing Starliner", "Satellite Payload", "boeing")
|
||||
|
||||
print("\nStarting Boeing Rocket Launch Simulation...")
|
||||
rocket.simulate_launch()
|
||||
|
||||
print("\nExecuting Boeing Precision Payload Deployment...")
|
||||
boeing.boeing_precision_payload_deployment(rocket)
|
||||
|
||||
print("\nExecuting Boeing Return and Landing...")
|
||||
boeing.boeing_return_and_landing(rocket)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,24 @@
|
|||
"""
|
||||
Module utilizing Lockheed Martin-specific operations for the RocketLaunch simulation.
|
||||
"""
|
||||
|
||||
from rocket_launcher import RocketLaunch
|
||||
from rocket_launcher import lockheed_martin
|
||||
|
||||
def main():
|
||||
"""
|
||||
Simulate a Lockheed Martin rocket launch with payload deployment and return operations.
|
||||
"""
|
||||
rocket = RocketLaunch("Lockheed Martin Atlas V", "Satellite Payload", "lockheed_martin")
|
||||
|
||||
print("\nStarting Lockheed Martin Rocket Launch Simulation...")
|
||||
rocket.simulate_launch()
|
||||
|
||||
print("\nExecuting Lockheed Martin Precision Payload Deployment...")
|
||||
lockheed_martin.lockheed_martin_payload_deployment(rocket)
|
||||
|
||||
print("\nExecuting Lockheed Martin Return and Landing...")
|
||||
lockheed_martin.lockheed_martin_return_and_landing(rocket)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python3
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
Module utilizing NASA-specific operations for the RocketLaunch simulation.
|
||||
"""
|
||||
|
||||
from rocket_launcher import RocketLaunch
|
||||
from rocket_launcher import nasa
|
||||
|
||||
def main():
|
||||
"""
|
||||
Simulate a NASA rocket launch with Curiosity rover mission operations.
|
||||
"""
|
||||
rocket = RocketLaunch("NASA Mars Mission", "Curiosity Rover", "nasa")
|
||||
|
||||
print("\nStarting NASA Rocket Launch Simulation...")
|
||||
rocket.simulate_launch()
|
||||
|
||||
print("\nExecuting Curiosity Rover Mission Operations...")
|
||||
nasa.curiosity_mission_operations(rocket)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env python3
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
"""
|
||||
Module utilizing SpaceX-specific operations for the RocketLaunch simulation.
|
||||
"""
|
||||
|
||||
from rocket_launcher import RocketLaunch
|
||||
from rocket_launcher import spacex
|
||||
|
||||
def main():
|
||||
"""
|
||||
Simulate a SpaceX rocket launch with booster recovery operations.
|
||||
"""
|
||||
rocket = RocketLaunch("SpaceX Falcon 9", "Satellite Payload", "spacex")
|
||||
|
||||
print("\nStarting SpaceX Rocket Launch Simulation...")
|
||||
rocket.simulate_launch()
|
||||
|
||||
print("\nExecuting SpaceX Booster Recovery...")
|
||||
spacex.spacex_booster_recovery(rocket)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
|
@ -0,0 +1,128 @@
|
|||
#!/usr/bin/env python3
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import time
|
||||
|
||||
class RocketLaunch:
|
||||
"""
|
||||
Class representing a rocket launch simulation with common functionality.
|
||||
|
||||
Attributes:
|
||||
- rocket_name (str): Name of the rocket.
|
||||
- payload (str): Description of the payload.
|
||||
- mission_type (str): Type of mission (e.g., 'curiosity', 'spacex', or 'standard').
|
||||
- current_stage (str): Current stage of the rocket launch.
|
||||
- stages (list): List of stages in the launch sequence.
|
||||
- stage_index (int): Index of the current stage in the stages list.
|
||||
- completed_stages (list): List of completed stages.
|
||||
|
||||
Methods:
|
||||
- initialize_stages: Initialize launch stages based on the mission type.
|
||||
- delay: Introduce a delay for a given number of seconds.
|
||||
- display_message: Display a message with an accompanying emoji.
|
||||
- advance_stage: Advance to the next stage in the launch sequence.
|
||||
- reset_launch: Reset the launch sequence.
|
||||
- simulate_launch: Simulate the entire launch sequence.
|
||||
"""
|
||||
|
||||
def __init__(self, rocket_name, payload, mission_type="standard"):
|
||||
"""
|
||||
Initialize a RocketLaunch instance.
|
||||
|
||||
Parameters:
|
||||
- rocket_name (str): Name of the rocket.
|
||||
- payload (str): Description of the payload.
|
||||
- mission_type (str): Type of mission (e.g., 'curiosity', 'spacex', or 'standard').
|
||||
"""
|
||||
self.rocket_name = rocket_name
|
||||
self.payload = payload
|
||||
self.mission_type = mission_type.lower()
|
||||
self.current_stage = "Initialization"
|
||||
self.stages = self.initialize_stages()
|
||||
self.stage_index = 0
|
||||
self.completed_stages = []
|
||||
|
||||
def initialize_stages(self):
|
||||
"""
|
||||
Initialize the stages based on the mission type.
|
||||
|
||||
Returns:
|
||||
list: List of stages for the launch.
|
||||
"""
|
||||
base_stages = [
|
||||
"Pre-Launch Preparations",
|
||||
"Ignition and Liftoff",
|
||||
"Ascent Stage",
|
||||
"Stage Separation",
|
||||
"Fairing Separation",
|
||||
"Orbital Insertion or Payload Deployment",
|
||||
"Stage Reentry and Recovery",
|
||||
"Post-Launch Operations"
|
||||
]
|
||||
if self.mission_type == "curiosity":
|
||||
base_stages.append("Curiosity Mission Operations")
|
||||
elif self.mission_type == "spacex":
|
||||
base_stages.append("SpaceX Booster Recovery")
|
||||
return base_stages
|
||||
|
||||
def delay(self, seconds=2):
|
||||
"""
|
||||
Introduce a delay for a given number of seconds.
|
||||
|
||||
Parameters:
|
||||
- seconds (int): Number of seconds to delay.
|
||||
"""
|
||||
time.sleep(seconds)
|
||||
|
||||
def display_message(self, message, emoji):
|
||||
"""
|
||||
Display a message with an accompanying emoji.
|
||||
|
||||
Parameters:
|
||||
- message (str): Message to be displayed.
|
||||
- emoji (str): Emoji to accompany the message.
|
||||
"""
|
||||
print(f"{emoji} {message}")
|
||||
self.delay()
|
||||
|
||||
def advance_stage(self):
|
||||
"""
|
||||
Advance to the next stage in the rocket launch sequence.
|
||||
Calls the method corresponding to the current stage.
|
||||
"""
|
||||
if self.stage_index < len(self.stages):
|
||||
self.current_stage = self.stages[self.stage_index]
|
||||
self.completed_stages.append(self.current_stage)
|
||||
print(f"\n--- Stage: {self.current_stage} ---")
|
||||
self.stage_index += 1
|
||||
else:
|
||||
print("🚀 Rocket launch sequence is complete! 🎉")
|
||||
|
||||
def reset_launch(self):
|
||||
"""
|
||||
Reset the launch sequence, allowing it to be restarted.
|
||||
"""
|
||||
self.current_stage = "Initialization"
|
||||
self.stage_index = 0
|
||||
self.completed_stages = []
|
||||
print(f"🔄 Launch sequence for {self.rocket_name} has been reset.")
|
||||
|
||||
def simulate_launch(self):
|
||||
"""
|
||||
Simulate the entire launch sequence.
|
||||
Advances through all stages and calls the respective methods for each stage.
|
||||
"""
|
||||
print(f"🚀 Starting launch sequence for {self.rocket_name} with payload: {self.payload} 🚀")
|
||||
while self.stage_index < len(self.stages):
|
||||
self.advance_stage()
|
||||
print("🎉 Launch sequence completed successfully! 🎉")
|
Binary file not shown.
|
@ -21,10 +21,6 @@ setup(
|
|||
author_email='dougsland@redhat.com, lrossett@redhat.com, dwalsh@redhat.com',
|
||||
license='Apache License 2.0',
|
||||
packages=find_packages(),
|
||||
install_requires=[
|
||||
'rclpy',
|
||||
'std_msgs',
|
||||
],
|
||||
classifiers=[
|
||||
'Programming Language :: Python :: 3',
|
||||
'License :: OSI Approved :: Apache Software License',
|
||||
|
|
|
@ -8,14 +8,16 @@ sudo dnf install qm -y
|
|||
```
|
||||
|
||||
```console
|
||||
# podman pull quay.io/qm-images/space-grade-linux:spaceship
|
||||
$ podman exec -it qm bash
|
||||
bash-5.2# podman pull quay.io/qm-images/space-grade-linux:spaceship
|
||||
bash-5.2# podman pull quay.io/qm-images/space-grade-linux:rocket_engine
|
||||
```
|
||||
|
||||
Create a specific network for the spaceship
|
||||
```bash
|
||||
podman network create --subnet=192.168.100.0/24 spaceship-net
|
||||
$ podman exec -it qm bash
|
||||
podman network create --subnet=192.168.100.0/24 spaceship-net
|
||||
```
|
||||
|
||||
```console
|
||||
|
|
Loading…
Reference in New Issue