Delete src/drone_data_collection.py with huggingface_hub
Browse files- src/drone_data_collection.py +0 -68
src/drone_data_collection.py
DELETED
|
@@ -1,68 +0,0 @@
|
|
| 1 |
-
import numpy as np
|
| 2 |
-
import os
|
| 3 |
-
import time
|
| 4 |
-
|
| 5 |
-
try:
|
| 6 |
-
from gym_pybullet_drones.envs.VelocityAviary import VelocityAviary
|
| 7 |
-
from gym_pybullet_drones.utils.Logger import Logger
|
| 8 |
-
from gym_pybullet_drones.utils.utils import sync, str2bool
|
| 9 |
-
except ImportError:
|
| 10 |
-
print("gym_pybullet_drones is not installed or available.")
|
| 11 |
-
print("Please make sure the environment is set up correctly.")
|
| 12 |
-
exit(1)
|
| 13 |
-
|
| 14 |
-
def collect_data(num_steps=8000, save_path="drone_dataset.npz"):
|
| 15 |
-
"""
|
| 16 |
-
Collects flight data for ESN training.
|
| 17 |
-
We will fly in a circle with varying height to generate dynamic states.
|
| 18 |
-
Inputs: 12D state (x,y,z, r,p,y, vx,vy,vz, wx,wy,wz)
|
| 19 |
-
Targets: 4D velocity ref (vx_ref, vy_ref, vz_ref, yaw_rate_ref)
|
| 20 |
-
"""
|
| 21 |
-
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
|
| 22 |
-
if not os.path.isabs(save_path):
|
| 23 |
-
save_path = os.path.join(BASE_DIR, save_path)
|
| 24 |
-
INIT_XYZS = np.array([[0, 0, .5]])
|
| 25 |
-
INIT_RPYS = np.array([[0, 0, 0]])
|
| 26 |
-
|
| 27 |
-
env = VelocityAviary(
|
| 28 |
-
gui=False,
|
| 29 |
-
record=False,
|
| 30 |
-
initial_xyzs=INIT_XYZS,
|
| 31 |
-
initial_rpys=INIT_RPYS
|
| 32 |
-
)
|
| 33 |
-
|
| 34 |
-
states = []
|
| 35 |
-
targets = []
|
| 36 |
-
|
| 37 |
-
obs, info = env.reset()
|
| 38 |
-
state = obs[0]
|
| 39 |
-
|
| 40 |
-
for i in range(num_steps):
|
| 41 |
-
# Generate some target velocities for a figure-8 or circle
|
| 42 |
-
t = i / 100.0
|
| 43 |
-
vx_ref = 0.5 * np.cos(t)
|
| 44 |
-
vy_ref = 0.5 * np.sin(t)
|
| 45 |
-
vz_ref = 0.1 * np.sin(t/2.0)
|
| 46 |
-
yaw_rate_ref = 0.2 * np.cos(t)
|
| 47 |
-
|
| 48 |
-
target_action = np.array([vx_ref, vy_ref, vz_ref, yaw_rate_ref])
|
| 49 |
-
|
| 50 |
-
# Save state and target
|
| 51 |
-
states.append(state)
|
| 52 |
-
targets.append(target_action)
|
| 53 |
-
|
| 54 |
-
# Step env (action is the target velocity)
|
| 55 |
-
obs, reward, terminated, truncated, info = env.step(np.array([target_action]))
|
| 56 |
-
state = obs[0]
|
| 57 |
-
|
| 58 |
-
env.close()
|
| 59 |
-
|
| 60 |
-
states = np.array(states)
|
| 61 |
-
targets = np.array(targets)
|
| 62 |
-
|
| 63 |
-
# Save the data
|
| 64 |
-
np.savez(save_path, states=states, targets=targets)
|
| 65 |
-
print(f"Data saved to {save_path}. Collected {len(states)} steps.")
|
| 66 |
-
|
| 67 |
-
if __name__ == "__main__":
|
| 68 |
-
collect_data(8000, "drone_dataset.npz")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|