LAB 4 – DRIVE

This lab combines lab2 Drive-by-wire with lab3 Cyclometer. The C3 Pilot computer requests the vehicle to drive a short distance at a given speed, and then stop. The wheels will be locked, so that we drive in a straight line or in a circle. Acceleration should follow a trapezoidal profile: ramp up the speed from zero until hitting the desired speed, then start to decelerate as the destination nears. It is tricky to avoid overshooting the target speed, while not taking too long to accelerate. Control Theory teaches formal methods to make this happen, but we will rely on intuition.


In addition to getting the control right, the other challenge of this lab is to establish communication between the processors. In lab2, the C2 drive-by-wire computer took analog inputs from the joystick. Instead, we will be taking the inputs from the C3 Pilot computer.


Table: DB25 connector between MegaShieldDB and MegaShieldTrio.


Pin Signal C2 destination C3/C4/C6 destination
1 LED6 D33 C6 D24
2 LED5 D31 C5 D13
3 LED4 D29 C4 D13
4 LED3 D27 C3 D13
5 LED1 D23 C6 D8
6 Cruise Steer A13 Cruise steer C6 A6, D6, C3 D6, (C6 D42 = C5 D6)
7 Cruise Brake A14 Cruise brake C6 A5, D5, C3 D5, (C6 D40 = C5 D5)
8 Cruise Throttle A15 Cruise Throttle C6 A7, D45, C3 D9, (C6 D48 = C5 D10)
9 Speed limit A8 C4 D9
10 Speed A12 C6 A13, C3 D11
11 Available D41 C6 D41, C4 D8, C5 D12
12 Available D39 C6 D39, C3 D12, C4 D10
13 Cruise Reverse D36 C3 D8, C6 D44, C5 D2
14 Available Jumper JP9 Pin 3
JP9-5 to D0 (RX0)
C6 D3 (INT1), X2
15 LED7 D35 C6 D22
16 LED8 D37 C6 D21
17 Move OK D4 C3 D10, C5 D10
18 Cruise Drive Command D15 (RX3) C3 D1 (TX), C6 D26
19 Available D14 (TX3) C6 D17 (RX2)
20 Vision In D17 (RX2) C6 D0 (RX0)
21 Wheel Click D3 (INT1) C6 D2 (INT0), X3
22 Vision Out D16 (TX2) C6 D1 (TX0)
23 Available A6 C6 D10
24 5V from brake servo none 5V
25 Ground Ground Ground

On the MegaShieldTrio board, C4 D1 (TX) goes to C3 D0 (RX) and to (C5 D0,RX = C6 D28). The board is most commonly built with three Arduinos: C3 Nano, C4 Nano, and C6 Mega. It is possible to build the board with four computers: C3 Nano, C4 Nano, C5 Nano and C6 Uno. It is safe to assume C5 does not exist.


C6 D16 (TX2) goes to C4 D0 (RX)


Thus the main serial path is C6 D16 (TX2) → C4 D0 (RX); C4 D1 (TX) → C3 D0 (RX); C3 D1 (TX) → C2 D15 (RX3); C2 D14 (TX3) → C6 D17 (RX2).


C6 acquires the speed and distance travelled from the wheel click interrupt. It transfers the information to C4, which passes it on to C3. C3 has been hard-coded with desired speed and distance. C3 will compute the appropriate values for throttle and brake, and send those to C2.


The standard serial libraries for Arduino assume that both the Rx and Tx lines are available. Even if the communication just goes one direction, there is handshaking information coming back on the other line. The Elcano communication is instead a round robin, but it has numerous digital lines that can be used as handshakes between processors.


Analog values for the throttle, brake and steering could be sent from C3 PWM pins D9, D5, and D6 through pins 6, 7, and 8 and received by C2 on analog inputs A15, A14, and A13. However, C3 cannot write a true analog, which would require C2 to measure the pulse width on each pin.


The preferred interface is to send a GameBots serial command from C3 to C2. This has the advantage that C2 can be replaced by the USARSim simulator. The subset of the Gamebots format used by the vehicle is:


DRIVE {Speed ComandedSpinSpeed} {FrontSteer ComandedSteerAngle}


Where:


{Speed ComandedSpinSpeed} ComandedSpinSpeed is a ‘float’ giving the spin speed for the rear wheel.


The value is the absolute spin speed, in radians per second.


{FrontSteer ComandedSteerAngle} ComandedSteerAngle is a ‘float’ that specifies the steer angle


of Elcano’s front wheels. The value is the absolute steer angle, in radians.


Example: DRIVE {Speed 2.59}{FrontSteer 0.0138}


A similar format will be used for sensed information from C6.


SENSOR {Speed SensedSpinSpeed}


SensedSpinSpeed is a ‘float’ giving the spin speed for the rear wheel.


The value is the speed in millimeters per second.


SOFTWARE



All these routines are in Lab4_Drive.


Status


(8/14/14): Hardware is ready. Software serial communications have been established. A version of MotionPilot has been written that runs on the Arduino Mega, combining the processing designed for C6, C4 and C3. This code has been tested and is able to receive a wheel click, transmit a serial sensor speed, read and decode that message, look up desired speed, and send that over a serial link to C2. Still need to test how the MotionPilot interacts with C2_Drive.


The C2 PID controller needs to be tuned.  See A. O’Dwyer, “An overview of tuning rules for the PI and PID continuous time control of delay single input, single output (SISO) processes”, PID Control in the Third Millennium, Springer, London, p. 3-44, 2012.