IS AIC

From LFS Manual
Jump to navigationJump to search
IS_AIC
Set AI control value
Overview
Size 4 + 4 * (number of inputs)
Type ISP_AIC (68)
Usage instruction
Previous packet
IS_IPB
Next packet
IS_AII

The AI Control packet is used to control an AI car programmatically.

Packet details

IS_AIC packet properties
Type Name Description
byte Size 4 + 4 * (number of inputs)
byte Type ISP_AIC
byte ReqI Optional - returned in any immediate response e.g. reply to CS_SEND_AI_INFO
byte PLID Unique ID of AI driver to control
AIInputVal Inputs [AIC_MAX_INPUTS]

Size

The size of the packet varies from 4 to 84 bytes depending on the number of Inputs.

Type

The packet type from the ISP_ enumeration, always ISP_AIC.

ReqI

ReqI is optional, it is returned in replies to this packet, e.g. when CS_SEND_AI_INFO is set.

PLID

The unique ID of the AI driver to control.

Inputs

The list of AIInputVal inputs to set on the AI car. Available inputs are the following:

// CS_MSX			 0 - steer: 1 hard left / 32768 centre / 65535 hard right
// CS_THROTTLE		 1 - 0 to 65535
// CS_BRAKE			 2 - 0 to 65535
// CS_CHUP			 3 - hold shift up lever
// CS_CHDN			 4 - hold shift down lever 
// CS_IGNITION		 5 - toggle
// CS_EXTRALIGHT	 6 - toggle
// CS_HEADLIGHTS	 7 - 1:off / 2:side / 3:low / 4:high
// CS_SIREN			 8 - hold siren - 1:fast / 2:slow
// CS_HORN			 9 - hold horn  - 1 to 5
// CS_FLASH			10 - hold flash - 1:on
// CS_CLUTCH		11 - 0 to 65535
// CS_HANDBRAKE		12 - 0 to 65535
// CS_INDICATORS	13 - 1: cancel / 2: left / 3: right / 4: hazard
// CS_GEAR			14 - for shifter (leave at 255 for sequential control)
// CS_LOOK			15 - 0: none / 4: left / 5: left+ / 6: right / 7: right+
// CS_PITSPEED		16 - toggle
// CS_TCDISABLE		17 - toggle
// CS_FOGREAR		18 - toggle
// CS_FOGFRONT		19 - toggle

Inputs marked 'hold' must be set back to zero after some time. This can be done either by use of the Time field or by sending a later packet with Value = 0. For instance, set Time to 10 when issuing a CS_CHUP to hold the shift up lever for 0.1 s.

Inputs marked 'toggle' accept the following values:

  • 1: toggle
  • 2: switch off
  • 3: switch on

There are also some special values available for Input:

#define CS_SEND_AI_INFO		240
#define CS_REPEAT_AI_INFO	241

#define CS_SET_HELP_FLAGS	253
#define CS_RESET_INPUTS		254
#define CS_STOP_CONTROL		255

CS_SEND_AI_INFO will result in an IS_AII packet being sent.

CS_REPEAT_AI_INFO starts or stops sending regular IS_AII packets, the interval is given in hundredths of a second.

CS_SET_HELP_FLAGS allows setting the following PIF_ player flags:

  • PIF_AUTOGEARS
  • PIF_HELP_B
  • PIF_AUTOCLUTCH

AI drivers default to PIF_AUTOCLUTCH only.

CS_RESET_INPUTS resets all inputs (zero everywhere except CS_MSX 32768 and CS_GEAR 255).

CS_STOP_CONTROL stops AI control, the AI driver stops the car entirely.

Notes

You cannot retrieve the state of the AI inputs, so you need to keep track of them if you need them. It is assumed that controls are updated very frequently, so that your latest commands are the current AI inputs.


Initialisation IS_ISI
Version Information IS_VER
General Purpose IS_TINY · IS_SMALL · IS_TTC
State Reporting and Requests IS_STA · IS_SFP · IS_ISM
Text Messages and Key Presses IS_SCH · IS_MSO · IS_III · IS_MST · IS_MTC · IS_MSX · IS_MSL
Voting IS_VTN
Race Tracking IS_RST · IS_REO
Autocross IS_AXI · IS_AXO · IS_UCO · IS_OCO · IS_AXM
Connection Tracking IS_NCN · IS_CNL · IS_CPR · IS_ACR · IS_NCI · IS_SLC · IS_CIM
Car Tracking IS_NPL · IS_PLP · IS_PLL · IS_LAP · IS_SPX · IS_PIT · IS_PSF · IS_PLA · IS_PEN · IS_TOC · IS_FLG · IS_PFL · IS_FIN · IS_RES · IS_NLP · IS_MCI · IS_CRS · IS_CON · IS_OBH · IS_HLV · IS_CSC
Camera Control IS_SCC · IS_CPP
Replay Control IS_RIP
Screenshots IS_SSH
InSim Buttons IS_BFN · IS_BTN · IS_BTC · IS_BTT
AI Control IS_AIC · IS_AII
Other packets IS_MOD · IS_CCH · IS_PLC · IS_HCP · IS_JRR · IS_MAL · IS_PLH · IS_IPB