Simulation Control
This tutorial guides you through controlling the simulation environment in AirGen. You’ll learn how to spawn objects, manipulate their position and scale, destroy objects, and modify environmental conditions like time of day.
Notebook for this example can be found: Here
Getting Started
First, let’s import the necessary libraries and initialize a connection to the AirGen simulation environment:
The VehicleClient
class provides an interface to the underlying simulation, allowing us to modify the environment even without directly controlling a specific vehicle.
Spawning Objects in the Simulation
Let’s start by placing a cube in the simulation world. We’ll position it 20 meters in front of the current vehicle:
Manipulating Object Position
Once an object is spawned, we can modify its position at any time:
The simGetObjectPose
method retrieves the current position and orientation of any object in the simulation, while simSetObjectPose
allows us to update it.
Scaling Objects
We can also modify the size of objects in the simulation:
The scale is represented as a Vector3r object with x, y, and z components, allowing for non-uniform scaling if desired. This feature is useful for:
- Creating objects of custom sizes
- Implementing growth or shrinking effects
- Adjusting obstacle difficulty in robotic navigation scenarios
Removing Objects from the Simulation
When an object is no longer needed, we can remove it from the simulation:
The simDestroyObject
method completely removes an object from the simulation environment. This can be used to:
- Clean up temporary objects
- Remove obstacles after they’ve served their purpose
Controlling Environmental Conditions
Beyond manipulating individual objects, AirGen allows control over environmental conditions. Let’s change the time of day:
The simSetTimeOfDay
method takes two parameters:
is_enabled
: Whether to enable custom time of day (True) or use the system time (False)datetime_str
: A string representing the desired date and time in “YYYY-MM-DD HH:MM:SS” format
This feature allows you to:
- Test robotic systems under different lighting conditions
- Simulate day/night transitions
- Create specific time-based scenarios