30 #include "mogi/thread.h" 34 #define TIME_HEARTBEAT_FAIL_STEERING (1.0) // In seconds, time until a heartbeat fails from not receiving a new steering command 35 #define TIME_HEARTBEAT_FAIL_ACCELERATION (1.0) // In seconds, time until a heartbeat fails from not receiving a new acceleration command 37 #define TOYOTA_COMMAND_THREAD_RATE (600.0) // Defines the rate of the thread, not for any particular command to be sent. 38 #define TOYOTA_RATE_HEARTBEAT (1.0) // This is for the panda in general, not Toyota specific 39 #define TOYOTA_RATE_LKA (1.0) // Rate of the LKAS_HUD command 40 #define TOYOTA_RATE_TRACK_B (40.0) // Rate of the TRACK_B_1 command 41 #define TOYOTA_RATE_STEER (100.0) // Rate of the STEERING_LKA command 42 #define TOYOTA_RATE_ACC (30.0) // Rate of the ACC_CONTROL command 44 #define TOYOTA_DECIMATOR_MAX_HEARTBEAT (TOYOTA_COMMAND_THREAD_RATE/TOYOTA_RATE_HEARTBEAT) 45 #define TOYOTA_DECIMATOR_MAX_LKA (TOYOTA_COMMAND_THREAD_RATE/TOYOTA_RATE_LKA) 46 #define TOYOTA_DECIMATOR_MAX_TRACK_B (TOYOTA_COMMAND_THREAD_RATE/TOYOTA_RATE_TRACK_B) 47 #define TOYOTA_DECIMATOR_MAX_STEER (TOYOTA_COMMAND_THREAD_RATE/TOYOTA_RATE_STEER) 48 #define TOYOTA_DECIMATOR_MAX_ACC (TOYOTA_COMMAND_THREAD_RATE/TOYOTA_RATE_ACC) 62 CanFrame buildLkasHud(
bool lkaAlert,
unsigned char leftLane,
unsigned char rightLane,
bool barrier,
bool twoBeeps,
bool repeatedBeeps);
134 void sendHeartBeat();
141 void triggerInstantLkaSend();
147 bool heartbeatSteeringPass();
148 bool heartbeatAccelerationPass();
153 int decimatorHeartbeat;
160 unsigned char counterSteer;
161 unsigned char counterTrackB;
166 unsigned char hudLeftLane;
167 unsigned char hudRightLane;
169 bool hudRepeatedBeeps;
172 double steerTorqueControl;
174 unsigned char steerLkaState;
177 double accelerationControl;
179 bool releaseStandstill;
185 int heartBeatAcceleration;
217 void setHudLanes(
unsigned char laneLeft,
unsigned char laneRight );
A class that handles the Usb, GPS, and CAN data.
Definition: panda.h:50
Handles USB communication and parsing with a comma.ai Panda.
Definition: can.h:38
void setHudMiniCar(bool enable)
Displays the "Mini Car" on the HUD.
A threaded interface class that handles sending contorl commands to a Panda via a Panda::Handler...
Definition: toyota.h:121
void setHudLanes(unsigned char laneLeft, unsigned char laneRight)
Shows different lanes for the right and left side. Valid values 0-3:
CanFrame buildDSU_CRUISE(unsigned char SET_SPEED)
Unused by ToyotaHandler. Also untested.
void printFrame(Panda::CanFrame frame)
This funciton is helpful for debugging but should either not live in toyota.h or shoul dbe removed: ...
void setSteerTorque(int steerTorque)
Sends a steering torque to the steering wheel (non-working).
Abstract class, handles a single thread. Features mutual exclusion and pause/resume.
Definition: thread.h:27
bool getIgnitionOn()
Returns the Panda report for whether the ignition is on (line).
CanFrame buildPCM_CRUISE_2(unsigned char SET_SPEED)
Unused by ToyotaHandler. Also untested.
ToyotaHandler(Panda::Handler *handler)
Construction must be done with a Panda::Handler.
const PandaHealth & getPandaHealth() const
Returns the full Panda Health state. controls_allowed and ignition_line can be read form this...
void setHudBarrier(bool enable)
Shows lane barriers on the HUD.
CanFrame buildTRACK_B_1(unsigned char count)
Constructs the TRACK_B_1 command, needed to fake adaptive cruise controller operation. Note that there could be more things to fake in this command, but for use of ACC_CONTROL this command is intercepted to prevent run-time faults of the ACC.
void setHudRepeatedBeeps(bool enable)
Will cause continuous beeping.
void setAcceleration(double acceleration)
Sends acceleration to the cruise controller, in units of m/s^2.
CanFrame buildLkasHud(bool lkaAlert, unsigned char leftLane, unsigned char rightLane, bool barrier, bool twoBeeps, bool repeatedBeeps)
Constructs the LKAS_HUS command that works on a Toyota RAV4.
CanFrame buildACC_CONTROL(double acc, bool permitBraking, bool releaseStandstill, bool miniCar, bool cancelRequest)
Constructs the ACC_CONTROL command, used for sending cruise cntrol accelerations. ...
void setHudTwoBeeps(bool enable)
Will cause a double-beep alert. Appears to be inconsistent in operation.
CanFrame buildSteeringLKA(unsigned char count, int16_t steerTorque, bool steerRequest, unsigned char lkaState)
Constructs the STEERING_LKA command, used for sending steering torque.
void setHudLdaAlert(bool enable)
Tells the driver to grab the steering wheel.
uint8_t toyotaChecksum(Panda::CanFrame &frame)
Computes particular checksums within the CAN message, and is not the CRC for the CAN frame itself...
bool getControlsAllowed()
Returns the Panda health report for whether controls are allowed. Controls are allowed when the cruis...
void setHudCruiseCancelRequest(bool enable)
Invokes a cruise control cancel request, for the driver to take control over vehicle. This will disable cruise control. Commands can only be sent to the car again if the driver re-activates cruise control.