libpandac  0.0.0
A library designed for a comm.ai Panda.
Public Member Functions | List of all members
Panda::ToyotaHandler Class Reference

A threaded interface class that handles sending contorl commands to a Panda via a Panda::Handler. More...

#include <toyota.h>

Inheritance diagram for Panda::ToyotaHandler:
Inheritance graph
Collaboration diagram for Panda::ToyotaHandler:
Collaboration graph

Public Member Functions

 ToyotaHandler (Panda::Handler *handler)
 Construction must be done with a Panda::Handler. More...
 
void setHudLdaAlert (bool enable)
 Tells the driver to grab the steering wheel. More...
 
void setHudBarrier (bool enable)
 Shows lane barriers on the HUD. More...
 
void setHudLanes (unsigned char laneLeft, unsigned char laneRight)
 Shows different lanes for the right and left side. Valid values 0-3: More...
 
void setHudTwoBeeps (bool enable)
 Will cause a double-beep alert. Appears to be inconsistent in operation. More...
 
void setHudRepeatedBeeps (bool enable)
 Will cause continuous beeping. More...
 
void setHudMiniCar (bool enable)
 Displays the "Mini Car" on the HUD. More...
 
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. More...
 
void setSteerTorque (int steerTorque)
 Sends a steering torque to the steering wheel (non-working). More...
 
void setAcceleration (double acceleration)
 Sends acceleration to the cruise controller, in units of m/s^2. More...
 
bool getIgnitionOn ()
 Returns the Panda report for whether the ignition is on (line). More...
 
bool getControlsAllowed ()
 Returns the Panda health report for whether controls are allowed. Controls are allowed when the cruise control is turned on and active from a SET press. This will get disabled by many events. Consider the following sequences with the corresponding return result of this function: More...
 
const PandaHealth & getPandaHealth () const
 Returns the full Panda Health state. controls_allowed and ignition_line can be read form this. More...
 
- Public Member Functions inherited from Mogi::Thread
bool start ()
 Starts the internal thread method. More...
 
void stop ()
 Stops the internal thread method. More...
 
void WaitForInternalThreadToExit ()
 Will wait until the thread has finished.
 
int lock ()
 Performs a mutual exclusion lock. Will halt if locked by another thread, and will resume when the other thread performs an unlock. More...
 
int unlock ()
 Performs a mutual exclusion unlock. Will allow other threads that have been locked to resume. More...
 
void pause ()
 Performs a pause. More...
 
void resume ()
 Resumes the thread from a pause. More...
 
bool running ()
 Returns the state of the thread. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Mogi::Thread
void checkSuspend ()
 Blocks the thread from a pause() call until resume() is called.
 

Detailed Description

A threaded interface class that handles sending contorl commands to a Panda via a Panda::Handler.

This is the intended methodology for sending control commands for a toyota with TSS2.0. Tested on a RAV4 2019.

Constructor & Destructor Documentation

Panda::ToyotaHandler::ToyotaHandler ( Panda::Handler handler)

Construction must be done with a Panda::Handler.

Parameters
handlerThe active interface for the Panda. The handler should be initialed with Panda::Handler::initialize() before Toyota::Handler::start() is called.

Member Function Documentation

bool Panda::ToyotaHandler::getControlsAllowed ( )

Returns the Panda health report for whether controls are allowed. Controls are allowed when the cruise control is turned on and active from a SET press. This will get disabled by many events. Consider the following sequences with the corresponding return result of this function:

Example sequence 1:
0. Be Parked: 0
  1. Before Cruise control enabled: 0
  2. Cruise control button pushed, enabling cruise: 0
  3. SET pushed while still in Park: 0
  4. SET pushed after shifting to Drive with brake held: 1
  5. Brake released: 1
  6. Brake pushed again: 0
  7. controlsAreAllowed will only return 0 unless cruise is cancelled or reset at this stage
Example sequence 2:
0. Be Driving before Cruise control enabled: 0
  1. Cruise control button pushed, enabling cruise: 0
  2. SET pushed while moving in drive: 1
  3. Brake pushed OR Throttle pushed: 0
  4. SET pushed again: 0
  5. Cancel pushed, then SET pushed: 1
Note
Note: When the brake is pushed to cancel, the HUD "SET" and radar will also disappear. However when the throttle is pressed, "SET" does not disappear even though controls are no longer allowed
This only gets updated at 1Hz from TOYOTA_RATE_HEARTBEAT
Returns
Whether the Panda will allow controls to be sent to the vehicle.
bool Panda::ToyotaHandler::getIgnitionOn ( )

Returns the Panda report for whether the ignition is on (line).

Note: The Panda also reports "ignition_can but appears to always be off in the RAV4. This only gets updated at 1Hz from TOYOTA_RATE_HEARTBEAT.
Returns
Whether the ignition is turned on or off.
const PandaHealth& Panda::ToyotaHandler::getPandaHealth ( ) const

Returns the full Panda Health state. controls_allowed and ignition_line can be read form this.

Returns
The last read state of the panda's state
void Panda::ToyotaHandler::setAcceleration ( double  acceleration)

Sends acceleration to the cruise controller, in units of m/s^2.

The comma.ai panda code has the following limits for acceleration:
const int TOYOTA_MAX_ACCEL = 1500; // 1.5 m/s^2
const int TOYOTA_MIN_ACCEL = -3000; // -3.0 m/s^2
The following limits can be achieved by setting the panda into "unsafe" mode:
const int TOYOTA_ISO_MAX_ACCEL = 2000; // 2.0 m/s^2
const int TOYOTA_ISO_MIN_ACCEL = -3500; // -3.5 m/s^2
The DBC file however has a different supported range of -20:20
Parameters
accelerationThe acceleration to be sent. Units are m/s^2, valid range is always -3.0:1.5
void Panda::ToyotaHandler::setHudBarrier ( bool  enable)

Shows lane barriers on the HUD.

Parameters
enableWhether the barriers should be displayed
void Panda::ToyotaHandler::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.

Parameters
enableWhether to invoke the Cancel Request
void Panda::ToyotaHandler::setHudLanes ( unsigned char  laneLeft,
unsigned char  laneRight 
)

Shows different lanes for the right and left side. Valid values 0-3:

0: Off 1: White 2: Hollow white 3: Blinking orange
Parameters
laneLeftThe setting for the left lane
rightLeftThe setting for the right lane
void Panda::ToyotaHandler::setHudLdaAlert ( bool  enable)

Tells the driver to grab the steering wheel.

Parameters
enableWhether the "Grab Steering Wheel" alert should be displayed
void Panda::ToyotaHandler::setHudMiniCar ( bool  enable)

Displays the "Mini Car" on the HUD.

Cruise control must be both on and active from "SET" being pushed for this to appear. If ACC is SET and not RES, (i.e. starting cruise from a standstill) then MiniCar will blink. Otherwise MiniCar is solid.
Parameters
enableWhether the Mini Car should be displayed in the HUD.
void Panda::ToyotaHandler::setHudRepeatedBeeps ( bool  enable)

Will cause continuous beeping.

Parameters
enableWhether the repeated beeping should be played
void Panda::ToyotaHandler::setHudTwoBeeps ( bool  enable)

Will cause a double-beep alert. Appears to be inconsistent in operation.

Parameters
enableWhether the Two Beeps should be played
void Panda::ToyotaHandler::setSteerTorque ( int  steerTorque)

Sends a steering torque to the steering wheel (non-working).

The comma.ai panda code has the following limits for steerTorque:
const int TOYOTA_MAX_TORQUE = 1500; // max torque cmd allowed ever
Parameters
steerTorqueThe steering torque to be sent. Valid range is -1500:1500

The documentation for this class was generated from the following file: