Skip to content
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
38 changes: 22 additions & 16 deletions BalloonPoppingGymEnv/envs/balloon_world.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,10 @@ def __init__(self, render_mode, parameters):
dtype=np.float64,
),
"tvc": spaces.Box(
low=-self.rocket_parameters["control"]["gimbal_range"] * np.ones(2),
high=self.rocket_parameters["control"]["gimbal_range"] * np.ones(2),
low=-self.rocket_parameters["control"]["max_gimbal_angle"]
* np.ones(2),
high=self.rocket_parameters["control"]["max_gimbal_angle"]
* np.ones(2),
dtype=np.float64,
),
"throttle": spaces.Box(
Expand Down Expand Up @@ -213,8 +215,12 @@ def step(self, action):
self.__init_rocket_simulation()
else: # Apply action to step the rocket simulation and get sensor measurements
self._rocket_flight.rocket.roll_control.roll_torque = action["roll"]
self._rocket_flight.rocket.tvc.gimbal_angle_x = action["tvc"][0]
self._rocket_flight.rocket.tvc.gimbal_angle_y = action["tvc"][1]
self._rocket_flight.rocket.thrust_vector_control.gimbal_angle_x = action[
"tvc"
][0]
self._rocket_flight.rocket.thrust_vector_control.gimbal_angle_y = action[
"tvc"
][1]
self._rocket_flight.rocket.throttle_control.throttle = action["throttle"]
self._rocket_flight.step_simulation()
_sensor = self._rocket_flight.sensors
Expand All @@ -233,7 +239,7 @@ def step(self, action):
"rocket_states": self._rocket_states.copy().tolist(),
"balloon_states": self._balloon_states.copy().tolist(),
"balloon_status": self._balloon_status[:, 0].tolist(),
}
}
if self.trajectories is None:
self.trajectories = [step_record]
else:
Expand Down Expand Up @@ -926,12 +932,12 @@ def tvc_controller_function(
tvc.gimbal_angle_y,
)

rocket.add_tvc(
gimbal_range=control_cfg["gimbal_range"],
gimbal_rate_limit=control_cfg["gimbal_rate_limit"],
sampling_rate=1 / self.simulation_parameters["time_step"],
rocket.add_thrust_vector_control(
controller_function=tvc_controller_function,
return_controller=False,
sampling_rate=1 / self.simulation_parameters["time_step"],
max_gimbal_angle=control_cfg["max_gimbal_angle"],
gimbal_rate_limit=control_cfg["gimbal_rate_limit"],
gimbal_time_constant=control_cfg["gimbal_time_constant"],
)

def roll_controller_function(
Expand All @@ -950,11 +956,11 @@ def roll_controller_function(
)

rocket.add_roll_control(
controller_function=roll_controller_function,
sampling_rate=1 / self.simulation_parameters["time_step"],
max_roll_torque=control_cfg["max_roll_torque"],
torque_rate_limit=control_cfg["torque_rate_limit"],
sampling_rate=1 / self.simulation_parameters["time_step"],
controller_function=roll_controller_function,
return_controller=False,
roll_torque_time_constant=control_cfg["roll_torque_time_constant"],
)

def throttle_controller_function(
Expand All @@ -973,11 +979,11 @@ def throttle_controller_function(
)

rocket.add_throttle_control(
controller_function=throttle_controller_function,
sampling_rate=1 / self.simulation_parameters["time_step"],
throttle_range=control_cfg["throttle_range"],
throttle_rate_limit=control_cfg["throttle_rate_limit"],
sampling_rate=1 / self.simulation_parameters["time_step"],
controller_function=throttle_controller_function,
return_controller=False,
throttle_time_constant=control_cfg["throttle_time_constant"],
)

self._rocket_flight = Flight(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ rocket:
- gnss_altitude_accuracy
- gnss_velocity_accuracy
control:
- gimbal_range
- max_gimbal_angle
- gimbal_rate_limit
- gimbal_time_constant
- max_roll_torque
- torque_rate_limit
- roll_torque_time_constant
- throttle_range
- throttle_rate_limit
- throttle_time_constant
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ environment:
enable: false
altitude_spacing: 10.0 # (m) vertical spacing between gust samples
max_gust_speed: 3.0 # (m/s) maximum gust speed
gust_decay_height: 150.0 # (m) characteristic decay height for the gust speed with altitude
gust_decay_height: 150.0 # (m) characteristic decay height for the gust speed with altitude

# Simulation timing configuration
simulation:
Expand Down Expand Up @@ -105,9 +105,13 @@ rocket:
gnss_altitude_accuracy: 0.0 # (m) altitude accuracy of the GNSS receiver
gnss_velocity_accuracy: 0.0 # (m/s) velocity accuracy of the GNSS receiver
control:
gimbal_range: 15 # (deg) maximum gimbal angle in any direction
max_gimbal_angle: 15 # (deg) maximum gimbal angle in any direction
gimbal_rate_limit: 60 # (deg/s) maximum gimbal rate
gimbal_time_constant: null # 1st order low pass filter time constant for actuator dynamics. null to turn off.
max_roll_torque: 10 # (N*m) maximum roll torque
torque_rate_limit: 20 # (N*m/s) maximum roll torque rate
roll_torque_time_constant: null # 1st order low pass filter time constant for actuator dynamics. null to turn off.
throttle_range: [0.0, 1.0] # range of the throttle (0 to 1)
throttle_rate_limit: 2.0 # (1/s) maximum throttle rate
throttle_time_constant: null # 1st order low pass filter time constant for actuator dynamics. null to turn off.

Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ rocket:
- gnss_altitude_accuracy
- gnss_velocity_accuracy
control:
- gimbal_range
- max_gimbal_angle
- gimbal_rate_limit
- gimbal_time_constant
- max_roll_torque
- torque_rate_limit
- roll_torque_time_constant
- throttle_range
- throttle_rate_limit
- throttle_time_constant
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ environment:
enable: false
altitude_spacing: 10.0 # (m) vertical spacing between gust samples
max_gust_speed: 3.0 # (m/s) maximum gust speed
gust_decay_height: 150.0 # (m) characteristic decay height for the gust speed with altitude
gust_decay_height: 150.0 # (m) characteristic decay height for the gust speed with altitude

# Simulation timing configuration
simulation:
Expand Down Expand Up @@ -105,9 +105,12 @@ rocket:
gnss_altitude_accuracy: 0.0 # (m) altitude accuracy of the GNSS receiver
gnss_velocity_accuracy: 0.0 # (m/s) velocity accuracy of the GNSS receiver
control:
gimbal_range: 15 # (deg) maximum gimbal angle in any direction
max_gimbal_angle: 15 # (deg) maximum gimbal angle in any direction
gimbal_rate_limit: 60 # (deg/s) maximum gimbal rate
gimbal_time_constant: null # 1st order low pass filter time constant for actuator dynamics. null to turn off.
max_roll_torque: 10 # (N*m) maximum roll torque
torque_rate_limit: 20 # (N*m/s) maximum roll torque rate
roll_torque_time_constant: null # 1st order low pass filter time constant for actuator dynamics. null to turn off.
throttle_range: [0.0, 1.0] # range of the throttle (0 to 1)
throttle_rate_limit: 2.0 # (1/s) maximum throttle rate
throttle_time_constant: null # 1st order low pass filter time constant for actuator dynamics. null to turn off.
Loading