Delete CarController.py
Browse files- CarController.py +0 -80
CarController.py
DELETED
|
@@ -1,80 +0,0 @@
|
|
| 1 |
-
from dataclasses import dataclass
|
| 2 |
-
import airsim
|
| 3 |
-
import time
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
@dataclass
|
| 7 |
-
class Carinfo():
|
| 8 |
-
speed_a = 0
|
| 9 |
-
speed_l = 0
|
| 10 |
-
|
| 11 |
-
pos_x = 0
|
| 12 |
-
pos_y = 0
|
| 13 |
-
pos_z = 0
|
| 14 |
-
|
| 15 |
-
rot_x = 0
|
| 16 |
-
rot_y = 0
|
| 17 |
-
rot_z = 0
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
class CarController():
|
| 21 |
-
def __init__(self):
|
| 22 |
-
# connect to the AirSim simulator
|
| 23 |
-
self.client = airsim.CarClient()
|
| 24 |
-
self.client.confirmConnection()
|
| 25 |
-
self.client.enableApiControl(True)
|
| 26 |
-
self.car_controls = airsim.CarControls()
|
| 27 |
-
|
| 28 |
-
def GoForward(self, v):
|
| 29 |
-
self.car_controls.throttle = v
|
| 30 |
-
self.car_controls.steering = 0
|
| 31 |
-
self.client.setCarControls(self.car_controls)
|
| 32 |
-
|
| 33 |
-
def GoBackwardStart(self, v):
|
| 34 |
-
self.car_controls.throttle = v
|
| 35 |
-
self.car_controls.is_manual_gear = True
|
| 36 |
-
self.car_controls.manual_gear = -1
|
| 37 |
-
self.car_controls.steering = 0
|
| 38 |
-
self.client.setCarControls(self.car_controls)
|
| 39 |
-
|
| 40 |
-
def GoBackwardEnd(self):
|
| 41 |
-
self.car_controls.throttle = 0
|
| 42 |
-
self.car_controls.steering = 0
|
| 43 |
-
self.car_controls.is_manual_gear = False
|
| 44 |
-
self.car_controls.manual_gear = 0
|
| 45 |
-
self.client.setCarControls(self.car_controls)
|
| 46 |
-
|
| 47 |
-
def Steer(self, v, steering):
|
| 48 |
-
self.car_controls.throttle = v
|
| 49 |
-
self.car_controls.steering = steering
|
| 50 |
-
self.client.setCarControls(self.car_controls)
|
| 51 |
-
|
| 52 |
-
def Stop(self):
|
| 53 |
-
self.car_controls.throttle = 0
|
| 54 |
-
self.car_controls.steering = 0
|
| 55 |
-
self.client.setCarControls(self.car_controls)
|
| 56 |
-
|
| 57 |
-
def GetCarPose(self):
|
| 58 |
-
position = self.client.simGetVehiclePose().position
|
| 59 |
-
rotation = self.client.simGetVehiclePose().orientation
|
| 60 |
-
|
| 61 |
-
speed_a = self.client.getCarState().speed
|
| 62 |
-
speed_l = self.client.getCarState().speed
|
| 63 |
-
|
| 64 |
-
carinfo = Carinfo()
|
| 65 |
-
|
| 66 |
-
carinfo.rot_x = rotation.x_val
|
| 67 |
-
carinfo.rot_y = rotation.y_val
|
| 68 |
-
carinfo.rot_z = rotation.z_val
|
| 69 |
-
|
| 70 |
-
carinfo.pos_x = position.x_val
|
| 71 |
-
carinfo.pos_y = position.y_val
|
| 72 |
-
carinfo.pos_z = position.z_val
|
| 73 |
-
|
| 74 |
-
carinfo.speed_a = speed_a
|
| 75 |
-
carinfo.speed_l = speed_l
|
| 76 |
-
|
| 77 |
-
return carinfo
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
carcontrol = CarController()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|