Advanced Mode
Load External Modules in GRID
The GRID notebook interface is designed to be flexible, allowing installation and use of external Python modules similar to Google Colab. This enables experimentation with different versions of libraries or the addition of new dependencies. It is important to note that all installed packages and defined variables are temporary and will be reset once the session ends.
Example: Installing a custom package:
To leverage the capabilities of the stable-baselines3 package for reinforcement learning, it can be easily installed within the GRID environment using a pip command.
Install the `stable-baselines3` Package
The package can be installed using the following command:
!pip install stable-baselines3
Import and Use `stable-baselines3`
After installation, the package can be imported and utilized as needed:
from stable_baselines3 import PPO # Example: Create a model model = PPO('MlpPolicy', 'CartPole-v1', verbose=1) model.learn(total_timesteps=10000)
Note
Upon restarting the session, all installed modules will be cleared. Reinstallation is necessary for each new session, ensuring a fresh environment every time.
Data Storage
The GRID platform provides cloud storage for each user to store data outputs from sessions. This storage can be navigated and viewed through the tab named "Storage" in the I/O panel. Every session started through GRID gets assigned its own 'folder' within this storage where the logs and the notebook are stored, along with any custom data the user saves manually.
When opening the Storage tab, it navigates to the directory where the data was saved by default. Incase you don't see the data already, please click on the refresh icon on the top right.
Logging any custom data (such as synthetic data from the simulation, model outputs, etc.) to the session storage can be achieved from the Python notebook. The storage can be targeted from the Python notebook through the GRID_USER_SESSION_BLOB_DIR
object. For instance, to log images generated from the above car simulation to the storage, the following code can be run:
import os
from grid import GRID_USER_SESSION_BLOB_DIR
from airgen import ImageType
from PIL import Image
# Get images from the drone
images = car.getImages("front_center", [ImageType.Scene])
# Assuming 'images' is a list of numpy arrays representing images
for i, img_array in enumerate(images):
# Convert the numpy array to an image
image = Image.fromarray(img_array)
# Define the path to save the image
save_path = os.path.join(GRID_USER_SESSION_BLOB_DIR, f"drone_image_{i}.png")
# Save the image as a PNG file
image.save(save_path)
In this way, any data you generate, such as images from the car, drone, etc, can be stored efficiently in the session storage provided by the GRID platform. This ensures that all your session outputs are organized and easily accessible.
After running this code, if you navigate to the current session folder in the Storage tab and click on the refresh button, you should see the saved drone images.
Example Workflow
For a simple car client in a simulation, the following steps briefly outline the data capture process:
Initialize Car Controls: Set up the vehicle's control parameters, such as throttle.
Choose Capture Types: Define the types of data to capture, such as IMU, LiDAR, RGB images, etc.
HDF5 File Creation: Create relevant groups in the HDF5 file to store the captured data.
Capture Data in a Loop: Use loops to capture multiple frames of data, ensuring comprehensive data collection over time.
By following these guidelines and using the provided code snippets, you can efficiently capture and store both sensor and image data from your simulations.
Note
The generated data will be available for download from the GRID portal even after the session has been terminated. Please find your data saved in the data storage section of the platform.