Skip to content

Commit

Permalink
[Pythonclient] Fix unused var warning, add docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
rajat2004 committed Apr 12, 2020
1 parent a903ce0 commit 2a48aa7
Showing 1 changed file with 27 additions and 16 deletions.
43 changes: 27 additions & 16 deletions PythonClient/airsim/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,18 @@ class ImageResponse(MsgpackMixin):
image_type = ImageType.Scene

class CarControls(MsgpackMixin):
"""
Struct to store values Car Controls
Attributes:
throttle (float): Throttle value, -1.0 to 1.0
steering (float): Steering value, -1.0 to 1.0
brake (float): Brake value, -1.0 o 1.0
handbrake (bool): Handbrake applied or not
is_manual_gear (bool): Gear appliead manually or not
manual_gear (int): Value of gear
gear_immediate (bool): Immediate Gear
"""
throttle = 0.0
steering = 0.0
brake = 0.0
Expand All @@ -301,16 +313,15 @@ def __init__(self, throttle = 0, steering = 0, brake = 0,
self.manual_gear = manual_gear
self.gear_immediate = gear_immediate


def set_throttle(self, throttle_val, forward):
if (forward):
is_manual_gear = False
manual_gear = 0
throttle = abs(throttle_val)
self.is_manual_gear = False
self.manual_gear = 0
self.throttle = abs(throttle_val)
else:
is_manual_gear = False
manual_gear = -1
throttle = - abs(throttle_val)
self.is_manual_gear = False
self.manual_gear = -1
self.throttle = - abs(throttle_val)

class KinematicsState(MsgpackMixin):
position = Vector3r()
Expand Down Expand Up @@ -409,7 +420,7 @@ class PIDGains():
"""
Struct to store values of PID gains. Used to transmit controller gain values while instantiating
AngleLevel/AngleRate/Velocity/PositionControllerGains objects.
Attributes:
kP (float): Proportional gain
kI (float): Integrator gain
Expand All @@ -426,7 +437,7 @@ def to_list(self):
class AngleRateControllerGains():
"""
Struct to contain controller gains used by angle level PID controller
Attributes:
roll_gains (PIDGains): kP, kI, kD for roll axis
pitch_gains (PIDGains): kP, kI, kD for pitch axis
Expand All @@ -438,14 +449,14 @@ def __init__(self, roll_gains = PIDGains(0.25, 0, 0),
self.roll_gains = roll_gains
self.pitch_gains = pitch_gains
self.yaw_gains = yaw_gains

def to_lists(self):
return [self.roll_gains.kp, self.pitch_gains.kp, self.yaw_gains.kp], [self.roll_gains.ki, self.pitch_gains.ki, self.yaw_gains.ki], [self.roll_gains.kd, self.pitch_gains.kd, self.yaw_gains.kd]

class AngleLevelControllerGains():
"""
Struct to contain controller gains used by angle rate PID controller
Attributes:
roll_gains (PIDGains): kP, kI, kD for roll axis
pitch_gains (PIDGains): kP, kI, kD for pitch axis
Expand All @@ -457,14 +468,14 @@ def __init__(self, roll_gains = PIDGains(2.5, 0, 0),
self.roll_gains = roll_gains
self.pitch_gains = pitch_gains
self.yaw_gains = yaw_gains

def to_lists(self):
return [self.roll_gains.kp, self.pitch_gains.kp, self.yaw_gains.kp], [self.roll_gains.ki, self.pitch_gains.ki, self.yaw_gains.ki], [self.roll_gains.kd, self.pitch_gains.kd, self.yaw_gains.kd]

class VelocityControllerGains():
"""
Struct to contain controller gains used by velocity PID controller
Attributes:
x_gains (PIDGains): kP, kI, kD for X axis
y_gains (PIDGains): kP, kI, kD for Y axis
Expand All @@ -476,14 +487,14 @@ def __init__(self, x_gains = PIDGains(0.2, 0, 0),
self.x_gains = x_gains
self.y_gains = y_gains
self.z_gains = z_gains

def to_lists(self):
return [self.x_gains.kp, self.y_gains.kp, self.z_gains.kp], [self.x_gains.ki, self.y_gains.ki, self.z_gains.ki], [self.x_gains.kd, self.y_gains.kd, self.z_gains.kd]

class PositionControllerGains():
"""
Struct to contain controller gains used by position PID controller
Attributes:
x_gains (PIDGains): kP, kI, kD for X axis
y_gains (PIDGains): kP, kI, kD for Y axis
Expand All @@ -495,7 +506,7 @@ def __init__(self, x_gains = PIDGains(0.25, 0, 0),
self.x_gains = x_gains
self.y_gains = y_gains
self.z_gains = z_gains

def to_lists(self):
return [self.x_gains.kp, self.y_gains.kp, self.z_gains.kp], [self.x_gains.ki, self.y_gains.ki, self.z_gains.ki], [self.x_gains.kd, self.y_gains.kd, self.z_gains.kd]

Expand Down

0 comments on commit 2a48aa7

Please sign in to comment.