Developer World
Spresense SDK Library v3.2.0-ebc0364
TRAnsport Mode rcognition API

Files

file  transport_mode_command.h
 

Classes

struct  ScuSettings
 
class  TramClass
 
struct  TramDebugDumpInfo
 
struct  SensorInitTram
 
struct  SensorExecTram
 
struct  SensorFlushTram
 
struct  SensorResultTram
 the structure of sensor result on transport mode commands. More...
 
struct  SensorCmdTram
 the structure of transport mode commands. More...
 

Macros

#define TRAM_NUMBER_OF_MODES   13
 
#define ACCEL_SAMPLING_FREQUENCY_MS   16
 
#define ACCEL_SAMPLING_FREQUENCY_CMD   64
 
#define ACCEL_SAMPLING_FREQUENCY_TMI   64
 
#define ACCEL_WATERMARK_NUM   320
 
#define ACCEL_FIFO_NUM   (ACCEL_WATERMARK_NUM * 2)
 
#define ACCEL_TRIGGER_RISE_THRESS   50
 
#define ACCEL_TRIGGER_RISE_COUNT0   2
 
#define ACCEL_TRIGGER_RISE_COUNT1   20
 
#define ACCEL_TRIGGER_RISE_DELAY   0
 
#define ACCEL_TRIGGER_FALL_THRESS   49
 
#define ACCEL_TRIGGER_FALL_COUNT0   2
 
#define ACCEL_TRIGGER_FALL_COUNT1   4
 
#define ACCEL_TRIGGER_FALL_DELAY   0
 
#define GET_SCU_ACCEL_SAMPLING_FREQUENCY(_x_)   (512 / (1 << (_x_)))
 
#define MAG_SAMPLING_FREQUENCY   8
 
#define MAG_WATERMARK_NUM   40
 
#define TRAM_ACC_SAMPLING   64
 
#define TRAM_MAG_SAMPLING   8
 
#define TRAM_BAR_SAMPLING   8
 

Enumerations

enum  tram_state_e {
  TRAM_STATE_UNINITIALIZED = 0 , TRAM_STATE_MS , TRAM_STATE_CMD , TRAM_STATE_TMI ,
  TRAM_STATE_NUM
}
 
enum  TramEvent { MathFuncEvent }
 
enum  TramNotification { ChangeScuSettings }
 
enum  TramCmdType { TramCmdTypeResult = 0 , TramCmdTypeTrans , TramCmdTypeNum }
 
enum  TramState { TramStateMs = 0 , TramStateCmd , TramStateTmi , TramStateNum }
 
enum  TramSensorType { TramSensorAcc = 0 , TramSensorMag , TramSensorBar }
 
enum  {
  TRAM_CLASS_UNDETERMINED = 0 , TRAM_CLASS_STAY , TRAM_CLASS_WALK , TRAM_CLASS_RUN ,
  TRAM_CLASS_UPSTAIRS , TRAM_CLASS_DOWNSTAIRS , TRAM_CLASS_ESCUP , TRAM_CLASS_ESCDOWN ,
  TRAM_CLASS_ELEVUP , TRAM_CLASS_ELEVDOWN , TRAM_CLASS_TRAIN , TRAM_CLASS_BUS ,
  TRAM_CLASS_CAR , TRAM_CLASS_BICYCLE
}
 

Functions

TramClassTramCreate (MemMgrLite::PoolId cmd_pool_id)
 Create TramClass instance. More...
 
int TramOpen (FAR TramClass *ins, FAR float *likelihood=NULL)
 Load TRAM library and boot up as worker task. After booted up, send initialize and wait complete. More...
 
int TramClose (FAR TramClass *ins)
 Destory TRAM worker task. More...
 
int TramStart (FAR TramClass *ins)
 Start TRAM with Dsp analysing. More...
 
int TramStop (FAR TramClass *ins)
 Stop TRAM with Dsp analysing. More...
 
int TramWrite (FAR TramClass *ins, FAR sensor_command_data_mh_t *command)
 Send data to TRAM worker task. More...
 
int TramHandleEvent (FAR TramClass *ins, TramEvent event)
 Send event to TRAM to handle event. More...
 
struct ScuSettingsTramGetAccelScuSettings (FAR TramClass *ins)
 Get settings information of accelerator. More...
 

Detailed Description

Macro Definition Documentation

◆ TRAM_NUMBER_OF_MODES

#define TRAM_NUMBER_OF_MODES   13

Number of transportation mode

◆ ACCEL_SAMPLING_FREQUENCY_MS

#define ACCEL_SAMPLING_FREQUENCY_MS   16

Accel sensor frequency in MS state[Hz]

◆ ACCEL_SAMPLING_FREQUENCY_CMD

#define ACCEL_SAMPLING_FREQUENCY_CMD   64

Accel sensor frequency in CMD state[Hz]

◆ ACCEL_SAMPLING_FREQUENCY_TMI

#define ACCEL_SAMPLING_FREQUENCY_TMI   64

Accel sensor frequency in TMI state[Hz]

◆ ACCEL_WATERMARK_NUM

#define ACCEL_WATERMARK_NUM   320

Accel sensor sample data watermark

◆ ACCEL_FIFO_NUM

#define ACCEL_FIFO_NUM   (ACCEL_WATERMARK_NUM * 2)

FIFO sample data watermark

◆ ACCEL_TRIGGER_RISE_THRESS

#define ACCEL_TRIGGER_RISE_THRESS   50

Accel sensor rise threshold

◆ ACCEL_TRIGGER_RISE_COUNT0

#define ACCEL_TRIGGER_RISE_COUNT0   2

Accel sensor rise preventing counts

◆ ACCEL_TRIGGER_RISE_COUNT1

#define ACCEL_TRIGGER_RISE_COUNT1   20

Accel sensor rise actual counts

◆ ACCEL_TRIGGER_RISE_DELAY

#define ACCEL_TRIGGER_RISE_DELAY   0

Rise event notification delay in samples

◆ ACCEL_TRIGGER_FALL_THRESS

#define ACCEL_TRIGGER_FALL_THRESS   49

Accel sensor fall threshold

◆ ACCEL_TRIGGER_FALL_COUNT0

#define ACCEL_TRIGGER_FALL_COUNT0   2

Accel sensor fall preventing counts

◆ ACCEL_TRIGGER_FALL_COUNT1

#define ACCEL_TRIGGER_FALL_COUNT1   4

Accel sensor fall actual counts

◆ ACCEL_TRIGGER_FALL_DELAY

#define ACCEL_TRIGGER_FALL_DELAY   0

Fall event notification delay in samples

◆ GET_SCU_ACCEL_SAMPLING_FREQUENCY

#define GET_SCU_ACCEL_SAMPLING_FREQUENCY (   _x_)    (512 / (1 << (_x_)))

sampling rate = 32768 / 64 / (2 ^ (x) )Hz

◆ MAG_SAMPLING_FREQUENCY

#define MAG_SAMPLING_FREQUENCY   8

Mag sensor frequency[Hz]

◆ MAG_WATERMARK_NUM

#define MAG_WATERMARK_NUM   40

Mag sensor sample data watermark

◆ TRAM_ACC_SAMPLING

#define TRAM_ACC_SAMPLING   64

Accelerometer sensor sampling frequency[Hz]

◆ TRAM_MAG_SAMPLING

#define TRAM_MAG_SAMPLING   8

Magnetmeter sensor sampling frequency[Hz]

◆ TRAM_BAR_SAMPLING

#define TRAM_BAR_SAMPLING   8

Barometer sensor sampling frequency[Hz]

Enumeration Type Documentation

◆ tram_state_e

TRAM state

Enumerator
TRAM_STATE_UNINITIALIZED 

uninitialized state

TRAM_STATE_MS 

motion sensing state

TRAM_STATE_CMD 

continuous motion detection state

TRAM_STATE_TMI 

transportation mode inference state

◆ TramEvent

enum TramEvent

TRAM event type

Enumerator
MathFuncEvent 

Math function request from SCU

◆ TramNotification

TRAM result type

Enumerator
ChangeScuSettings 

SCU setting change request from TRAM

◆ TramCmdType

Command type

Enumerator
TramCmdTypeResult 

Result of command

TramCmdTypeTrans 

Notification of state transition

◆ TramState

enum TramState

TRAM state

Enumerator
TramStateMs 

MS state

TramStateCmd 

CMD state

TramStateTmi 

TMI state

◆ TramSensorType

Sensor type

Enumerator
TramSensorAcc 

Accelerometer

TramSensorMag 

Magnetmeter

TramSensorBar 

Barometer

◆ anonymous enum

anonymous enum

Result of transportation mode inference

Enumerator
TRAM_CLASS_UNDETERMINED 

Undetermined

TRAM_CLASS_STAY 

Staying

TRAM_CLASS_WALK 

Walking

TRAM_CLASS_RUN 

Running

TRAM_CLASS_UPSTAIRS 

Ascending stairs

TRAM_CLASS_DOWNSTAIRS 

Descending stairs

TRAM_CLASS_ESCUP 

Going up on escalator

TRAM_CLASS_ESCDOWN 

Going down on escalator

TRAM_CLASS_ELEVUP 

Going up in elevator

TRAM_CLASS_ELEVDOWN 

Going down in elevator

TRAM_CLASS_TRAIN 

Getting on train

TRAM_CLASS_BUS 

Getting on bus

TRAM_CLASS_CAR 

Getting in car

TRAM_CLASS_BICYCLE 

Riding bicycle

Function Documentation

◆ TramCreate()

TramClass * TramCreate ( MemMgrLite::PoolId  cmd_pool_id)

Create TramClass instance.

Parameters
[in]cmd_pool_id: Pool id for DSP communication data
Returns
Address for instance of TramClass

◆ TramOpen()

int TramOpen ( FAR TramClass ins,
FAR float *  likelihood = NULL 
)

Load TRAM library and boot up as worker task. After booted up, send initialize and wait complete.

Parameters
[in]ins: instance address of TramClass
[in]likelihood: buffer address to contain likelihood
Returns
result of process.

◆ TramClose()

int TramClose ( FAR TramClass ins)

Destory TRAM worker task.

Parameters
[in]ins: instance address of TramClass
Returns
result of process.

◆ TramStart()

int TramStart ( FAR TramClass ins)

Start TRAM with Dsp analysing.

Parameters
[in]ins: instance address of TramClass
Returns
result of process.

◆ TramStop()

int TramStop ( FAR TramClass ins)

Stop TRAM with Dsp analysing.

Parameters
[in]ins: instance address of TramClass
Returns
result of process.

◆ TramWrite()

int TramWrite ( FAR TramClass ins,
FAR sensor_command_data_mh_t command 
)

Send data to TRAM worker task.

Parameters
[in]ins: instance address of TramClass
[in]command: command including data to send
Returns
result of process

◆ TramHandleEvent()

int TramHandleEvent ( FAR TramClass ins,
TramEvent  event 
)

Send event to TRAM to handle event.

Parameters
[in]ins: instance address of TramClass
[in]event: event to handle
Returns
result of process

◆ TramGetAccelScuSettings()

struct ScuSettings * TramGetAccelScuSettings ( FAR TramClass ins)

Get settings information of accelerator.

Parameters
[in]ins: instance address of TramClass
Returns
pointer of settings information