Skip to content

Commit ccb549a

Browse files
authored
Merge pull request #255 from AGIJens/master
initial add of single segment mode example
2 parents 7d7eaa1 + 4620f55 commit ccb549a

File tree

2 files changed

+244
-64
lines changed

2 files changed

+244
-64
lines changed
Lines changed: 166 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,166 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"id": "9fd37373-d1c6-4e27-aef0-a8f6fc5fc979",
6+
"metadata": {},
7+
"source": [
8+
"#### this script demostrates the use of single segment mode (or individual segment mode)\n",
9+
"##### it will create a new satellite and raise apogee to 10000 km using small maneuvers at perigee using single segment mode. This is similar to the auto-sequence tutorial. The script assumes a scenario is open and does not contain a satellite named SingleSegmentSat\n",
10+
"##### author: jens ramrath, agi\n",
11+
"##### date: 23 oct 2024"
12+
]
13+
},
14+
{
15+
"cell_type": "markdown",
16+
"id": "6e82508a-32be-479b-961f-427f006b95d3",
17+
"metadata": {},
18+
"source": [
19+
"### connect to running instance of STK"
20+
]
21+
},
22+
{
23+
"cell_type": "code",
24+
"execution_count": null,
25+
"id": "bed5a81c-df08-4274-8fed-b44de3a94c76",
26+
"metadata": {},
27+
"outputs": [],
28+
"source": [
29+
"from agi.stk12.stkdesktop import STKDesktop\n",
30+
"from agi.stk12.stkobjects import *\n",
31+
"from agi.stk12.stkobjects.astrogator import *\n",
32+
"\n",
33+
"stk = STKDesktop.AttachToApplication()\n",
34+
"root = stk.Root\n",
35+
"sc = root.CurrentScenario\n",
36+
"\n",
37+
"print('connected to ' + sc.InstanceName)"
38+
]
39+
},
40+
{
41+
"cell_type": "markdown",
42+
"id": "bb783e0a-c93e-4d41-a22b-6458dc8f7689",
43+
"metadata": {},
44+
"source": [
45+
"### create new satellite and set up MCS\n",
46+
"we'll have\n",
47+
"1. Initial State - keep the default\n",
48+
"2. Propagate - replace Duration stopping condition with Periapsis\n",
49+
"3. Maneuver - 20 m/sec intrack"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"id": "6c8ed73e-e6d4-41d2-ab4e-dd08c97e631b",
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"# create new satellite\n",
60+
"sat = sc.Children.New(AgESTKObjectType.eSatellite, 'SingleSegmentSat')\n",
61+
"sat.SetPropagatorType(AgEVePropagatorType.ePropagatorAstrogator)\n",
62+
"prop = sat.Propagator\n",
63+
"\n",
64+
"# initial state\n",
65+
"# get handle to initial state\n",
66+
"iSegment = prop.MainSequence.Item(0)\n",
67+
"\n",
68+
"# propagate\n",
69+
"# get handle to propagate segment\n",
70+
"pSegment = prop.MainSequence.Item(1)\n",
71+
"# add periapsis stopping condition\n",
72+
"pSegment.StoppingConditions.Add('Periapsis')\n",
73+
"# remove default Duration stopping condition\n",
74+
"pSegment.StoppingConditions.Remove('Duration')\n",
75+
"# add apoapsis radius result so we can rasily query it\n",
76+
"pSegment.Results.Add('Radius of Apoapsis')\n",
77+
"\n",
78+
"# maneuver\n",
79+
"# add maneuver at end\n",
80+
"mSegment = prop.MainSequence.InsertByName('Maneuver', '-')\n",
81+
"# specify small thrust\n",
82+
"mSegment.Maneuver.AttitudeControl.DeltaVMagnitude = 0.02"
83+
]
84+
},
85+
{
86+
"cell_type": "markdown",
87+
"id": "f159b2b0-35fe-45ae-98ac-b2b596da7e7e",
88+
"metadata": {},
89+
"source": [
90+
"### RUN"
91+
]
92+
},
93+
{
94+
"cell_type": "code",
95+
"execution_count": null,
96+
"id": "d0c0598e-58a5-4d60-ada9-86af511cbdfc",
97+
"metadata": {},
98+
"outputs": [],
99+
"source": [
100+
"# start new run\n",
101+
"prop.BeginRun()\n",
102+
"\n",
103+
"# add initial state\n",
104+
"iSegment.Run()\n",
105+
"\n",
106+
"# add propagate segment\n",
107+
"pSegment.Run()\n",
108+
"\n",
109+
"# propagate\n",
110+
"prop.EndRun()\n",
111+
"\n",
112+
"# get final apo radius\n",
113+
"rop = pSegment.GetResultValue('Radius of Apoapsis')\n",
114+
"print('apogee radius: ' + str(rop))\n",
115+
"\n",
116+
"# add maneuver and propagate segments until perigee radius is above limit\n",
117+
"while rop < 10000:\n",
118+
" # last segment state\n",
119+
" rSegment = prop.MainSequence.GetItemByName('-')\n",
120+
" \n",
121+
" # append to last segment\n",
122+
" prop.AppendRun()\n",
123+
"\n",
124+
" # add maneuver and propagate\n",
125+
" mSegment.Run()\n",
126+
" pSegment.Run()\n",
127+
"\n",
128+
" # propagate\n",
129+
" prop.EndRun()\n",
130+
" \n",
131+
" # get apo radius\n",
132+
" rop = pSegment.GetResultValue('Radius of Apoapsis')\n",
133+
" print('apogee radius: ' + str(rop))"
134+
]
135+
},
136+
{
137+
"cell_type": "code",
138+
"execution_count": null,
139+
"id": "d293642a-19a1-4afe-87fb-d1f808ebb1f1",
140+
"metadata": {},
141+
"outputs": [],
142+
"source": []
143+
}
144+
],
145+
"metadata": {
146+
"kernelspec": {
147+
"display_name": "Python 3 (ipykernel)",
148+
"language": "python",
149+
"name": "python3"
150+
},
151+
"language_info": {
152+
"codemirror_mode": {
153+
"name": "ipython",
154+
"version": 3
155+
},
156+
"file_extension": ".py",
157+
"mimetype": "text/x-python",
158+
"name": "python",
159+
"nbconvert_exporter": "python",
160+
"pygments_lexer": "ipython3",
161+
"version": "3.10.9"
162+
}
163+
},
164+
"nbformat": 4,
165+
"nbformat_minor": 5
166+
}
Lines changed: 78 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,78 @@
1-
# Python Scenario Building Samples
2-
3-
## [Aviator_ObjectModel_CarrierLanding.py](Aviator_ObjectModel_CarrierLanding.py)
4-
5-
Creates a scenario that demonstrates an aircraft carrier landing using two Aviator aircraft with custom procedures. All inputs are available for editing, though this is better used as a reference for planning Aviator missions programmatically.
6-
7-
### Dependencies
8-
9-
* Licenses: [STK Premium Air](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-premium-air-brochure.pdf)
10-
* Other Scripts: N/A
11-
* Scenario: N/A
12-
13-
---
14-
15-
## [STK_OM_Tutorial](STK_OM_Tutorial)
16-
17-
STK Object Model Walkthrough using Python with comtypes. In the incomplete version, the user is meant to write lines where "Action" is requested in a comment. The comtypes interface is no longer the recommended way of interacting with STK via python (see the [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm) available in STK 12.1+), but this tutorial is helpful for understanding how the STK object model works. More tutorial content for the STK object model is available in the [Level 2 Integration Certification](https://register.agi.com/training/certification/?cert=integration).
18-
19-
### Dependencies
20-
21-
* Licenses: [STK Pro](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-pro-brochure.pdf)
22-
* Other Scripts: N/A
23-
* Scenario: N/A
24-
25-
---
26-
27-
## [AstrogatorObjectModel](AstrogatorObjectModel)
28-
29-
These notebooks walk you through an introduction to [STK Astrogator](https://help.agi.com/stk/index.htm#astrogator.htm) object model. The tutorial builds a LEO to GEO transfer using a combined inclination and apogee raise maneuver at GEO. The walkthrough demonstrates using a target sequence for a Hohmann Transfer. The comtypes interface is no longer the recommended way of interacting with STK via python (see the [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm?Highlight=python%20api) available in STK 12.1+), but this tutorial is helpful for understanding how the STK Astrogator object model works. More tutorial content for the STK object model is available in the [Level 2 Integration Certification](https://register.agi.com/training/certification/?cert=integration).
30-
31-
### Dependencies
32-
33-
* Licenses: [STK Premium Space](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-premium-space-brochure.pdf)
34-
* Other Scripts: N/A
35-
* Scenario: N/A
36-
37-
---
38-
39-
## [PythonAPI12.2_Demo](PythonAPI12.2_Demo)
40-
41-
Made with [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm) available in STK 12.1+
42-
43-
This script is a demo of the STK Python API that creates a complex search and rescue scenario using custom Aviator models and mission procedures. The only user input required is a Cesium Ion access code, but Cesium Ion buildings can be turned off in the variable list at the top of the script. This script should prove a useful tool for learning to use the Python API for creating Aviator and Communications objects. A custom 3D model of a Cessna 206 aircraft is included with this demo.
44-
45-
### Dependencies
46-
47-
* Licenses: [STK Premium Air](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-premium-air-brochure.pdf)
48-
* Other Scripts: N/A
49-
* Scenario: N/A
50-
51-
---
52-
## [VolumetricSensorCoverage](VolumetricSensorCoverage)
53-
54-
Performs an end-to-end volumetric coverage analysis with sensors. It will build a scenario with three GEO satellites, a volume grid that covers the GEO belt, and a volumetric object to perform the analysis.
55-
56-
There are two versions of the script, one leveraging comtypes and the other leveraging the [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm) available in STK 12.1+.
57-
58-
### Dependencies
59-
60-
* Licenses: [STK Pro](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-pro-brochure.pdf)
61-
* Other Scripts: N/A
62-
* Scenario: N/A
63-
64-
---
1+
# Python Scenario Building Samples
2+
3+
## [Aviator_ObjectModel_CarrierLanding.py](Aviator_ObjectModel_CarrierLanding.py)
4+
5+
Creates a scenario that demonstrates an aircraft carrier landing using two Aviator aircraft with custom procedures. All inputs are available for editing, though this is better used as a reference for planning Aviator missions programmatically.
6+
7+
### Dependencies
8+
9+
* Licenses: [STK Premium Air](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-premium-air-brochure.pdf)
10+
* Other Scripts: N/A
11+
* Scenario: N/A
12+
13+
---
14+
15+
## [STK_OM_Tutorial](STK_OM_Tutorial)
16+
17+
STK Object Model Walkthrough using Python with comtypes. In the incomplete version, the user is meant to write lines where "Action" is requested in a comment. The comtypes interface is no longer the recommended way of interacting with STK via python (see the [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm) available in STK 12.1+), but this tutorial is helpful for understanding how the STK object model works. More tutorial content for the STK object model is available in the [Level 2 Integration Certification](https://register.agi.com/training/certification/?cert=integration).
18+
19+
### Dependencies
20+
21+
* Licenses: [STK Pro](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-pro-brochure.pdf)
22+
* Other Scripts: N/A
23+
* Scenario: N/A
24+
25+
---
26+
27+
## [AstrogatorObjectModel](AstrogatorObjectModel)
28+
29+
These notebooks walk you through an introduction to [STK Astrogator](https://help.agi.com/stk/index.htm#astrogator.htm) object model. The tutorial builds a LEO to GEO transfer using a combined inclination and apogee raise maneuver at GEO. The walkthrough demonstrates using a target sequence for a Hohmann Transfer. The comtypes interface is no longer the recommended way of interacting with STK via python (see the [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm?Highlight=python%20api) available in STK 12.1+), but this tutorial is helpful for understanding how the STK Astrogator object model works. More tutorial content for the STK object model is available in the [Level 2 Integration Certification](https://register.agi.com/training/certification/?cert=integration).
30+
31+
### Dependencies
32+
33+
* Licenses: [STK Premium Space](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-premium-space-brochure.pdf)
34+
* Other Scripts: N/A
35+
* Scenario: N/A
36+
37+
---
38+
39+
## [SingleSegmentModeExample.ipynb](AstrogatorObjectModel)
40+
41+
This notebook gives an example or running Astrogator in single segment mode
42+
43+
### Dependencies
44+
45+
* Licenses: [STK Premium Space](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-premium-space-brochure.pdf)
46+
* Other Scripts: N/A
47+
* Scenario: N/A
48+
49+
---
50+
51+
52+
53+
## [PythonAPI12.2_Demo](PythonAPI12.2_Demo)
54+
55+
Made with [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm) available in STK 12.1+
56+
57+
This script is a demo of the STK Python API that creates a complex search and rescue scenario using custom Aviator models and mission procedures. The only user input required is a Cesium Ion access code, but Cesium Ion buildings can be turned off in the variable list at the top of the script. This script should prove a useful tool for learning to use the Python API for creating Aviator and Communications objects. A custom 3D model of a Cessna 206 aircraft is included with this demo.
58+
59+
### Dependencies
60+
61+
* Licenses: [STK Premium Air](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-premium-air-brochure.pdf)
62+
* Other Scripts: N/A
63+
* Scenario: N/A
64+
65+
---
66+
## [VolumetricSensorCoverage](VolumetricSensorCoverage)
67+
68+
Performs an end-to-end volumetric coverage analysis with sensors. It will build a scenario with three GEO satellites, a volume grid that covers the GEO belt, and a volumetric object to perform the analysis.
69+
70+
There are two versions of the script, one leveraging comtypes and the other leveraging the [Python API](https://help.agi.com/stkdevkit/index.htm#python/pythonGettingStarted.htm) available in STK 12.1+.
71+
72+
### Dependencies
73+
74+
* Licenses: [STK Pro](https://www.ansys.com/content/dam/amp/2022/june/webpage-requests/stk-product-page/brochures/stk-pro-brochure.pdf)
75+
* Other Scripts: N/A
76+
* Scenario: N/A
77+
78+
---

0 commit comments

Comments
 (0)