f1/10 autonomous racing reactive methods part 1 wall following · f1/10 autonomous racing reactive...

68
F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia)

Upload: others

Post on 15-Mar-2020

8 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

F1/10 Autonomous Racing

Reactive MethodsPart 1

Wall Following

Madhur Behl (University of Virginia)

Page 2: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

2

ssh [email protected]

Previously

Page 3: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

3

roslaunch move_base move_base.launch

TeleOp Test

Page 4: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

4

roslaunch move_base move_base.launch

Lets see how it works…

Page 5: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

5

CommandMultiplexer

MoveBase VESC

Joystick

AutonomousMode

On the Jetson TX2

Page 6: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

6

CommandMultiplexer

MoveBase VESC

Joystick

AutonomousMode

On the Jetson TX2

Page 7: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

7

CommandMultiplexer

Joystick

AutonomousMode

Steering value: [-100 (full left), 100 (full right)]

Speed value: [-100 (full reverse), 100 (full forward)]

Page 8: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

8

CommandMultiplexer

Joystick

AutonomousMode

Steering value: [-100 (full left), 100 (full right)] Speed value: [-100 (full reverse), 100 (full forward)]

Topic: '/car_1/offboard/command'

Topic: '/joy'

Message Type: AckermannDrive

Page 9: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

9

[-100,100][-100,100]

Only two fields are used

These do not matter and are set to 0 by default.

Page 10: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

10

CommandMultiplexer

MoveBase VESC

Joystick

AutonomousMode

On the Jetson TX2

Page 11: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

11

CommandMultiplexer

MoveBase

Chooses the mode:AutonomousOr TeleOp

Steering and Speed Values[-100,100] for both

Maps the range into float64 values for The VESC driver:

Steering:- [-100,100] is mapped to [0,1]

Speed:- [-100,100] is mapped to

[-20000,20000] RPM

Subscribes

Topic: rospy.Publisher(‘/car_1/multiplexer/command’)

Publishes

/car_1/commands/servo/position/car_1/commands/motor/speed

/car_1/footprint

Publishes

Page 12: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

12

CommandMultiplexer

MoveBase VESC

Joystick

AutonomousMode

On the Jetson TX2

Page 13: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

What is PWM – Pulse Width Modulation

• Output signal alternates between on and off within specified

period

• Controls power received by a device

• The voltage seen by the load is directly proportional to the

source voltage

Page 14: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Here is what 10V DC looks like..

Page 15: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Here is what 0V DC looks like..

Page 16: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Switch 10V ON half the time : 50% Duty Cycle

Page 17: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

10V DC: 50% duty cycle à average of 5V DC

Page 18: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Here is a case with 10% duty cycle..

Page 19: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 20: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 21: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Application to DC motors

• The voltage supplied to a DC motor is proportional to the duty cycle

• Both brushed and brushless motors can be used with PWM

• Both analog and digital control techniques and components are available

Page 22: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

22

VESC

vesc_driver.py

Sends PWM commands to Drive Motor and Steering Servo

Page 23: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

23

roslaunch move_base move_base.launch

TeleOp Test

Page 24: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

24

Let us study move_base.launch

listen_offboard : false -> TeleOp mode, true -> Autonomous Mode

Page 25: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

25

Let us study move_base.launch

move_base.py node is run

Page 26: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

26

Let us study move_base.launch

Command_multiplex.py node is runTakes the mode as input argument

Page 27: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

27

Let us study move_base.launch

Static transform between base_linkAnd laser

Page 28: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

28

Let us study move_base.launch

Note the port it looks for

Page 29: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

29

Let us study move_base.launch

Note the port it looks for

Page 30: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

30

Let us study move_base.launch

Page 31: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

31

Let us study move_base.launch

Page 32: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

32

Page 33: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

33

Page 34: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

34

Page 35: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

35

Page 36: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

36

Page 37: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

37

Page 38: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

38

Page 39: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

39

Page 40: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

40

Page 41: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Next:

Wall followingPID control

Page 42: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 43: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 44: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 45: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 46: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Account for the forward motion of the car

Error = desired trajectory – CD

Page 47: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID Steering Control

!"##$%&' (&')# = !"##$%&' (&')# − ,-

Page 48: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Field of View

ß Assumption

Reality à

Page 49: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Control

Proportional, Integral, Derivative control

Page 50: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: objectives

Control objective: 1) keep the car driving along the

centerline,

2) parallel to the walls.

Left Wall Right Wall

50

Page 51: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: objectives

Control objective: 1) keep the car driving along the

centerline,

2) parallel to the walls.

51

Page 52: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: objectives

Control objective: 1) keep the car driving (roughly) along

the centerline,

2) parallel to the walls.

52

Page 53: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: control objectives

Control objective: 1) keep the car driving along the

centerline,

y = 0

2) parallel to the walls.

Θ = 0x

y

Θ

53

Page 54: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: control objectives

Control objective: 1) keep the car driving along the

centerline,

y = 0

2) After driving L meters, it is still on the centerline:Horizontal distance after driving L meters

Lsin(Θ) = 0

54

x

y

Θ

Lsin(Θ)

L

AB

Page 55: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: control inputs

Control input:Steering angle Θ

We will hold the velocity constant.

How do we control the steering angle to keep

y = 0, Lsin(Θ) = 0as much as possible?

55

x

y

Θ

Lsin(Θ)

L

Page 56: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: error term

Want both y and Lsin(Θ) to be zero

àError term e(t) = -(y + Lsin(Θ))

We’ll see why we added a minus sign

56

x

y

Θ

Lsin(Θ)

L

Page 57: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: computing input

When y > 0, car is to the left of centerlineà Want to steer right: Θ < 0

When Lsin(Θ) > 0, we will be to the left of centerline in L metersà so want to steer right: Θ < 0

Set desired angle to be Θd = Kp (-y –Lsin(Θ))

57

x

y

Θ

Lsin(Θ)

L

Page 58: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: computing input

When y < 0, car is to the right of

centerline

à Want to steer left

àWant Θ > 0

When Lsin(Θ) < 0, we will be to the

right of centerline in L meters, so

want to steer left

àWant Θ > 0

Consistent with previous requirement:

Θd = Kp (-y –Lsin(Θ))

58

x

y

Θ

Lsin(Θ)

L

Page 59: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: Proportional control

Θd = C Kp (-y –Lsin(Θ)) = C Kp e(t)

This is Proportional control.

The extra C constant is for scaling distances to angles.

59

x

y

Θ

Lsin(Θ)

L

Page 60: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: Derivative control

If error term is increasing quickly, we might want the controller to react quickly

à Apply a derivative gain:Θ = Kp e (t)

+ Kd de(t)/dt

60

x

y

Θ

Lsin(Θ)

L

Page 61: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: Integral control

Integral control is proportional to the cumulative error

Θ = Kp e (t) + KI E (t) + Kd de (t)/dt

Where E(t) is the integral of the error up to time t (from a chosen reference time)

61

x

y

Θ

Lsin(Θ)

L

Page 62: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: tuning the gains

• Default set of gains, determined empirically to work well for this car.– Kp = 14– Ki = 0– Kd = 0.09

62

Page 63: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 64: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: tuning the gains

• Reduce Kp à less responsive to error magnitude– Kp = 5– Ki = 0– Kd = 0.09

64

Page 65: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 66: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

PID control: tuning the gains

• Include Ki à overly sensitive to accumulating error à over-correction– Kp = 14– Ki = 2– Kd = 0.09

66

Page 67: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1
Page 68: F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following · F1/10 Autonomous Racing Reactive Methods Part 1 Wall Following Madhur Behl (University of Virginia) 2 sshnvidia@192.168.1.1

Next Assignment..preview

• Implement Wall Following and demo in lab.

– We will mark a tape `X’ m away from the track boundary and

evaluate if your PID controller can maintain the desired distance ‘X’

away from the wall.

– Complete laps without crashing

• Implement Automatic Emergency Braking

– If an obstacle appears directly in front of the car, and closer than a

threshold distance during wall following, the car must come to an

immediate stop.

68