#include <Servo.h>
#include <Wire.h>
Defines | |
| #define | DEBUG 0 |
| Debug variable; Set to non-zero to print debugging information. | |
| #define | EncoderPinA 3 |
| First wheel encoder sensor. | |
| #define | EncoderPinB 5 |
| Second wheel encoder. | |
| #define | DELAY_TIME 200 |
| Reading delays. | |
| #define | WHEEL_CIRCUMFERENCE 0.9 |
| Wheel circumference, in meters. | |
| #define | WHEEL_TICKS 244 |
| The number of 'ticks' for a full wheel cycle. | |
| #define | MAX_SPEED 1.0 |
| Vehicle Maximum speed in m/s. | |
| #define | DrivePin 9 |
| Driving interface pin. | |
| #define | SteerPin 10 |
| Steering interface pin. | |
| #define | SteerInput 0 |
| The analog / manual steering input. | |
| #define | FRONT_SONAR 117 |
| Front sonar I2C address. | |
| #define | REAR_SONAR 116 |
| Rear sonar I2C address. | |
Functions | |
| void | InitializeHardware () |
| Initialize all hardware components. | |
| void | ReleaseHardware () |
| Release all hardware components. | |
| void | Update () |
| Update the current vehicle with speed and turn (Not in RC). | |
| void | SetSpeed () |
| Set the speed of the vehicle (Not in RC). | |
| void | SetSpeedDirect (int Speed) |
| Set speed directly. | |
| void | SetTurnDirect (int Turn) |
| Set turn directly. | |
| void | SetTurn () |
| Set the angle of the wheels. | |
| void | GetSpeed () |
| Post real-world vehicle speed. | |
| void | GetSteerAngle () |
| Post the Steering Angle. | |
| int | GetYaw () |
| Return the compass bearing, make sure to not query too fast. | |
| int | GetRange (int value) |
| void | EncoderEvent () |
| Wheel encoder interrupt event function. | |
Variables | |
| Servo | DriveServo |
| Servo interface object. | |
| Servo | SteerServo |
| Servo interface object. | |
| unsigned char | CompassAddress = 0x60 |
| Base offset for I2C device interface. | |
| volatile unsigned int | EncoderPos = 0 |
| Wheel encoder position; Note that it is volatile so an interrupt function call can access the memory. | |
| double | dVal = 0 |
| long | OldPos |
| Difference calculations for the wheel encoder. | |
| long | NewPos |
| unsigned long | LastSpeedUpdate = 0 |
| unsigned long | LastSteerUpdate = 0 |
| double | KpSpeed = 1 |
| double | KiSpeed = 0 |
| double | KdSpeed = 0 |
| double | KpSteer = 1 |
| double | KiSteer = .5 |
| double | KdSteer = 0 |
| double | SpeedIntegral = 0.0 |
| double | SteerIntegral = 0.0 |
| double | MaxSpeedIntegral = 10.0 |
| double | MaxSteerIntegral = 10.0 |
| double | LastSpeedError = 0.0 |
| double | LastSteerError = 0.0 |
| #define DEBUG 0 |
Debug variable; Set to non-zero to print debugging information.
| #define DELAY_TIME 200 |
Reading delays.
| #define DrivePin 9 |
Driving interface pin.
| #define EncoderPinA 3 |
First wheel encoder sensor.
| #define EncoderPinB 5 |
Second wheel encoder.
| #define FRONT_SONAR 117 |
Front sonar I2C address.
| #define MAX_SPEED 1.0 |
Vehicle Maximum speed in m/s.
| #define REAR_SONAR 116 |
Rear sonar I2C address.
| #define SteerInput 0 |
The analog / manual steering input.
| #define SteerPin 10 |
Steering interface pin.
| #define WHEEL_CIRCUMFERENCE 0.9 |
Wheel circumference, in meters.
| #define WHEEL_TICKS 244 |
The number of 'ticks' for a full wheel cycle.
| void EncoderEvent | ( | ) |
Wheel encoder interrupt event function.
| int GetRange | ( | int | value | ) |
| void GetSpeed | ( | ) |
Post real-world vehicle speed.
| void GetSteerAngle | ( | ) |
Post the Steering Angle.
| int GetYaw | ( | ) |
Return the compass bearing, make sure to not query too fast.
| void InitializeHardware | ( | ) |
Initialize all hardware components.
| void ReleaseHardware | ( | ) |
Release all hardware components.
| void SetSpeed | ( | ) |
Set the speed of the vehicle (Not in RC).
| void SetSpeedDirect | ( | int | Speed | ) |
Set speed directly.
| void SetTurn | ( | ) |
Set the angle of the wheels.
| void SetTurnDirect | ( | int | Turn | ) |
Set turn directly.
| void Update | ( | ) |
Update the current vehicle with speed and turn (Not in RC).
| unsigned char CompassAddress = 0x60 |
Base offset for I2C device interface.
| Servo DriveServo |
Servo interface object.
| double dVal = 0 |
| volatile unsigned int EncoderPos = 0 |
Wheel encoder position; Note that it is volatile so an interrupt function call can access the memory.
| double KdSpeed = 0 |
| double KdSteer = 0 |
| double KiSpeed = 0 |
| double KiSteer = .5 |
| double KpSpeed = 1 |
| double KpSteer = 1 |
| double LastSpeedError = 0.0 |
| unsigned long LastSpeedUpdate = 0 |
| double LastSteerError = 0.0 |
| unsigned long LastSteerUpdate = 0 |
| double MaxSpeedIntegral = 10.0 |
| double MaxSteerIntegral = 10.0 |
| long NewPos |
| long OldPos |
Difference calculations for the wheel encoder.
| double SpeedIntegral = 0.0 |
| double SteerIntegral = 0.0 |
| Servo SteerServo |
Servo interface object.
1.5.5