Basic Car Control

The wheeled robots can either be controlled through the keyboard, or through API functions. When a session is launched with a wheeled robot selected, keyboard control is enabled by default. Click on the simulation tab (to capture focus), and use the arrow keys to control the robot.

Steering/Speed Control

In order to switch to API control, you can run the first pre-written cell in the notebook. If you wish to switch to API control yourself manually, run the following command in a notebook cell.

airgen_car_0.client.enableApiControl(True)

Once API control is enabled, you can use the airgen.CarControls() class to set the control parameters for the car. CarControls contains the following parameters: throttle, brake, and steering. The commands can be sent in the following way:

car_controls = airgen.CarControls()
car_controls.throttle = 1
car_controls.brake = 0
car_controls.steering = 0.5
airgen_car_0.client.setCarControls(car_controls)

Speed Control

Instead of continuously controlling throttle, it is also possible to control the speed through setpoints - this mode can be enabled by calling enableCarSpeedControl(True), and disabled by passing False. Speed control can be achieved using the setCarTargetSpeed() function, like in the example below:

import time

airgen_car_0.client.enableCarSpeedControl(True)
airgen_car_0.client.setCarTargetSpeed(5.0) # Drive the car at 5 m/s
time.sleep(5)
airgen_car_0.client.setCarTargetSpeed(0.0) # Stop the car