KillzoneCC commited on
Commit ·
dc810fd
1
Parent(s): cca84d9
Исправленный код старого
Browse files- collect_and_upload.py +12 -8
collect_and_upload.py
CHANGED
|
@@ -29,7 +29,7 @@ ROSBRIDGE_PORT = 9090
|
|
| 29 |
REPO_ID = "KillzoneCCO/Ainex"
|
| 30 |
LOCAL_ROOT_DIR = Path("./")
|
| 31 |
|
| 32 |
-
# --- ROS Топики и типы сообщений для сбора данных
|
| 33 |
OBSERVATION_TOPICS = {
|
| 34 |
"camera_generic": {"topic": "/camera/image_raw", "msg_type": "sensor_msgs/Image"},
|
| 35 |
"imu": {"topic": "/imu", "msg_type": "sensor_msgs/Imu"},
|
|
@@ -193,7 +193,7 @@ def collect_data_and_save():
|
|
| 193 |
# --- Создание папок в правильном порядке ---
|
| 194 |
META_DIR = LOCAL_ROOT_DIR / "meta"
|
| 195 |
DATA_DIR = LOCAL_ROOT_DIR / "data" / "chunk-000"
|
| 196 |
-
VIDEOS_DIR = LOCAL_ROOT_DIR / "videos" / "
|
| 197 |
|
| 198 |
os.makedirs(META_DIR, exist_ok=True)
|
| 199 |
os.makedirs(DATA_DIR, exist_ok=True)
|
|
@@ -234,7 +234,7 @@ def collect_data_and_save():
|
|
| 234 |
"fps": 30,
|
| 235 |
"robot_type": "ainex_robot",
|
| 236 |
"data_path": "data/chunk-000/episode_{episode_index:06d}.parquet",
|
| 237 |
-
"video_path": "videos/
|
| 238 |
"features": {
|
| 239 |
"action": { "dtype": "float32", "shape": [26] },
|
| 240 |
"observation": {
|
|
@@ -243,7 +243,7 @@ def collect_data_and_save():
|
|
| 243 |
"images.generic": {
|
| 244 |
"dtype": "video",
|
| 245 |
"media_type": "video/mp4",
|
| 246 |
-
"path_format": "videos/
|
| 247 |
"shape": [480, 640, 3]
|
| 248 |
}
|
| 249 |
},
|
|
@@ -310,14 +310,18 @@ features:
|
|
| 310 |
|
| 311 |
if new_image_generic_data is not None:
|
| 312 |
img_generic, img_timestamp = new_image_generic_data
|
| 313 |
-
|
| 314 |
imu_data = latest_data["imu"][0] if latest_data["imu"] is not None else np.array([0.0]*10, dtype=np.float32)
|
| 315 |
joint_positions_data = latest_data["joint_positions"][0] if latest_data["joint_positions"] is not None else np.array([0.0]*26, dtype=np.float32)
|
| 316 |
|
| 317 |
all_images_generic.append(img_generic)
|
| 318 |
all_joint_positions.append(joint_positions_data.tolist())
|
| 319 |
all_imu_data.append(imu_data.tolist())
|
| 320 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 321 |
all_timestamps.append(img_timestamp)
|
| 322 |
|
| 323 |
latest_data["camera_generic"] = None
|
|
@@ -331,7 +335,7 @@ features:
|
|
| 331 |
create_video(all_images_generic, video_path_generic)
|
| 332 |
|
| 333 |
df = pd.DataFrame({
|
| 334 |
-
'observation.images.generic': [f"
|
| 335 |
'observation.joint_positions': all_joint_positions,
|
| 336 |
'observation.imu': all_imu_data,
|
| 337 |
'action.servo_commands': all_actions,
|
|
@@ -378,7 +382,7 @@ features:
|
|
| 378 |
create_video(all_images_generic, video_path_generic)
|
| 379 |
|
| 380 |
df = pd.DataFrame({
|
| 381 |
-
'observation.images.generic': [f"
|
| 382 |
'observation.joint_positions': all_joint_positions,
|
| 383 |
'observation.imu': all_imu_data,
|
| 384 |
'action.servo_commands': all_actions,
|
|
|
|
| 29 |
REPO_ID = "KillzoneCCO/Ainex"
|
| 30 |
LOCAL_ROOT_DIR = Path("./")
|
| 31 |
|
| 32 |
+
# --- ROS Топики и типы сообщений для сбора данных ---
|
| 33 |
OBSERVATION_TOPICS = {
|
| 34 |
"camera_generic": {"topic": "/camera/image_raw", "msg_type": "sensor_msgs/Image"},
|
| 35 |
"imu": {"topic": "/imu", "msg_type": "sensor_msgs/Imu"},
|
|
|
|
| 193 |
# --- Создание папок в правильном порядке ---
|
| 194 |
META_DIR = LOCAL_ROOT_DIR / "meta"
|
| 195 |
DATA_DIR = LOCAL_ROOT_DIR / "data" / "chunk-000"
|
| 196 |
+
VIDEOS_DIR = LOCAL_ROOT_DIR / "videos" / "observation.images.generic"
|
| 197 |
|
| 198 |
os.makedirs(META_DIR, exist_ok=True)
|
| 199 |
os.makedirs(DATA_DIR, exist_ok=True)
|
|
|
|
| 234 |
"fps": 30,
|
| 235 |
"robot_type": "ainex_robot",
|
| 236 |
"data_path": "data/chunk-000/episode_{episode_index:06d}.parquet",
|
| 237 |
+
"video_path": "videos/observation.images.generic/episode_{episode_index:06d}.mp4",
|
| 238 |
"features": {
|
| 239 |
"action": { "dtype": "float32", "shape": [26] },
|
| 240 |
"observation": {
|
|
|
|
| 243 |
"images.generic": {
|
| 244 |
"dtype": "video",
|
| 245 |
"media_type": "video/mp4",
|
| 246 |
+
"path_format": "videos/observation.images.generic/episode_{episode_index:06d}.mp4",
|
| 247 |
"shape": [480, 640, 3]
|
| 248 |
}
|
| 249 |
},
|
|
|
|
| 310 |
|
| 311 |
if new_image_generic_data is not None:
|
| 312 |
img_generic, img_timestamp = new_image_generic_data
|
| 313 |
+
|
| 314 |
imu_data = latest_data["imu"][0] if latest_data["imu"] is not None else np.array([0.0]*10, dtype=np.float32)
|
| 315 |
joint_positions_data = latest_data["joint_positions"][0] if latest_data["joint_positions"] is not None else np.array([0.0]*26, dtype=np.float32)
|
| 316 |
|
| 317 |
all_images_generic.append(img_generic)
|
| 318 |
all_joint_positions.append(joint_positions_data.tolist())
|
| 319 |
all_imu_data.append(imu_data.tolist())
|
| 320 |
+
|
| 321 |
+
# Assuming joint_positions are the actions/commands.
|
| 322 |
+
# If there's a separate topic for actions, subscribe to it and replace this line.
|
| 323 |
+
all_actions.append(joint_positions_data.tolist())
|
| 324 |
+
|
| 325 |
all_timestamps.append(img_timestamp)
|
| 326 |
|
| 327 |
latest_data["camera_generic"] = None
|
|
|
|
| 335 |
create_video(all_images_generic, video_path_generic)
|
| 336 |
|
| 337 |
df = pd.DataFrame({
|
| 338 |
+
'observation.images.generic': [f"videos/observation.images.generic/episode_{episode_idx:06d}.mp4"] * len(all_images_generic),
|
| 339 |
'observation.joint_positions': all_joint_positions,
|
| 340 |
'observation.imu': all_imu_data,
|
| 341 |
'action.servo_commands': all_actions,
|
|
|
|
| 382 |
create_video(all_images_generic, video_path_generic)
|
| 383 |
|
| 384 |
df = pd.DataFrame({
|
| 385 |
+
'observation.images.generic': [f"videos/observation.images.generic/episode_{episode_idx:06d}.mp4"] * len(all_images_generic),
|
| 386 |
'observation.joint_positions': all_joint_positions,
|
| 387 |
'observation.imu': all_imu_data,
|
| 388 |
'action.servo_commands': all_actions,
|