Skip to content

Commit

Permalink
Minor changes for better example running experience. Reset motor RPM …
Browse files Browse the repository at this point in the history
…at reset. Set damping coeff for position control.

Signed-off-by: Mihir Kulkarni <[email protected]>
  • Loading branch information
mihirk284 committed Dec 11, 2024
1 parent 7a77ada commit f24cc3b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 11 deletions.
12 changes: 6 additions & 6 deletions aerial_gym/config/robot_config/base_quad_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,22 +168,22 @@ class control_allocator_config:
]

class motor_model_config:
use_rps = True
use_rps = False

motor_thrust_constant_min = 0.00000926312
motor_thrust_constant_max = 0.00001826312

motor_time_constant_increasing_min = 0.09
motor_time_constant_increasing_max = 0.12
motor_time_constant_increasing_min = 0.03
motor_time_constant_increasing_max = 0.03

motor_time_constant_decreasing_min = 0.03
motor_time_constant_decreasing_max = 0.05
motor_time_constant_decreasing_min = 0.04
motor_time_constant_decreasing_max = 0.04

max_thrust = 2
min_thrust = 0

max_thrust_rate = 100000.0
thrust_to_torque_ratio = 0.01
use_discrete_approximation = (
False # Setting to false will compute f' based on difference and time constant
True # Setting to false will compute f' based on difference and time constant
)
11 changes: 6 additions & 5 deletions aerial_gym/control/motor_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def __init__(self, num_envs, motors_per_robot, dt, config, device="cuda:0"):
self.cfg = config
self.device = device
self.num_motors_per_robot = motors_per_robot
self.max_thrust = self.cfg.max_thrust
self.min_thrust = self.cfg.min_thrust
self.max_thrust = torch.tensor(self.cfg.max_thrust, device=self.device, dtype=torch.float32).expand(
self.num_envs, self.num_motors_per_robot
)
self.min_thrust = torch.tensor(self.cfg.min_thrust, device=self.device, dtype=torch.float32).expand(
self.num_envs, self.num_motors_per_robot
)
self.motor_time_constant_increasing_min = torch.tensor(
self.cfg.motor_time_constant_increasing_min, device=self.device
).expand(self.num_envs, self.num_motors_per_robot)
Expand Down Expand Up @@ -118,9 +122,6 @@ def reset_idx(self, env_ids):
self.motor_thrust_constant[env_ids] = torch_rand_float_tensor(
self.motor_thrust_constant_min, self.motor_thrust_constant_max
)[env_ids]
self.first_order_linear_mixing_factor[env_ids] = self.mixing_factor_function(
self.dt, self.motor_time_constants
)[env_ids]

def reset(self):
self.reset_idx(torch.arange(self.num_envs, device=self.device))
Expand Down
1 change: 1 addition & 0 deletions aerial_gym/robots/base_multirotor.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ def reset_idx(self, env_ids):
self.robot_state[env_ids, 10:13] = random_state[env_ids, 10:13]

self.controller.randomize_params(env_ids=env_ids)
self.control_allocator.reset_idx(env_ids)

# update the states after resetting because the RL agent gets the first state after reset
self.update_states()
Expand Down
3 changes: 3 additions & 0 deletions aerial_gym/robots/robot_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,9 @@ def add_robot_to_env(
props["stiffness"][j_index] = self.cfg.reconfiguration_config.stiffness[
j_index
]
props["damping"][j_index] = self.cfg.reconfiguration_config.damping[
j_index
]
elif self.cfg.reconfiguration_config.dof_mode == "velocity":
props["driveMode"].fill(gymapi.DOF_MODE_VEL)
for j_index in range(len(props["damping"])):
Expand Down

0 comments on commit f24cc3b

Please sign in to comment.