The Picar Module

class picar.device(name='D')

Base class for all Devices

whoAmI()

A function that could be called to tell what device it is

class picar.sensor(name='S')

Base class for all Sensors

detect()

A sensor should implement this method to tell if the sensor is currently available

getConn()

The connection could be returned by this function

getFieldSize()

A sensor should implement this method to return the field size requested by the sensor in logging file

getHeader()

A sensor should implement this method to return the header of it requested field in a list

getValue()

A sensor should implement this method to return values in a list

setConn(conn)

A sensor’s connection should be able to be reset by this function

whoAmI()

A function that could be called to tell what device it is

class picar.pmucounter(name='P')

PMU (Performance Monitoring Unit) reader

detect()

A sensor should implement this method to tell if the sensor is currently available

getConn()

The connection could be returned by this function

getFieldSize()

A sensor should implement this method to return the field size requested by the sensor in logging file

getHeader()

A sensor should implement this method to return the header of it requested field in a list

getValue()

A sensor should implement this method to return values in a list

setConn(conn)

A sensor’s connection should be able to be reset by this function

whoAmI()

A function that could be called to tell what device it is

class picar.IMU(name='I')

This class for IMU sensor

calibrate()

A wrapper for IMU calibration

detect()

This function tests if accel, gyro and mag are all available

getConn()

The connection could be returned by this function

getFieldSize()

Field size = 9

getHeader()

Header: AccelX, AccelY, AccelZ, GyroX, GyroY, GyroZ, MagX, MagY, MagZ

getValue()

Return a 9-elements list containing all IMU reading

setConn(conn)
Parameters:conn – an IMU object created by imu library
setIMUScale(aScl=2, gScl=245, mScl=4)

Scale for IMU_SETUP

Available rate for accel :
2, 4, 8, 16
Available rate for gyro :
245, 500, 2000
Available rate for mag :
4, 8, 12, 16

(Value set other than these value might cause IMU to crush)

setIMUodr(aRate=6, gRate=6, mRate=7)

Output rate setter for IMU

Available rate for accel :

1 = 10 Hz 4 = 238 Hz

2 = 50 Hz 5 = 476 Hz

3 = 119 Hz 6 = 952 Hz

Available rate for gyro :

1 = 14.9 4 = 238

2 = 59.5 5 = 476

3 = 119 6 = 952

Available rate for mag :

0 = 0.625 Hz 4 = 10 Hz

1 = 1.25 Hz 5 = 20 Hz

2 = 2.5 Hz 6 = 40 Hz

3 = 5 Hz 7 = 80 Hz

whoAmI()

A function that could be called to tell what device it is

class picar.LiDar(name='L')
detect()

A sensor should implement this method to tell if the sensor is currently available

getConn()

The connection could be returned by this function

getFieldSize()

FieldSize = 1

getHeader()

Header : LiDar

getValue()

Return a 1 element list

setConn(conn)
Parameters:conn – a serial port
whoAmI()

A function that could be called to tell what device it is

class picar.Camera(name='C', res=(480, 480), fr=40)
capture(gen, *args)
Parameters:
  • gen – a filename generator that has timing functionality
  • *args – contains all the arguments gen needs
setFrameRate(fr)
Parameters:fr – int in Hz
setRes(res)
Parameters:res – resolution (length,width) in a tuple
whoAmI()

A function that could be called to tell what device it is

class picar.Timer(kit, gap)

A Timer class that helps get delta timing for a sensor

read(t)
Parameters:t – current time to be compared with the time kept by the object
class picar.Killer(state)

A elegant killer, to make sure the process and subprocesses functions as expected

picar.pre_exec()

Easy to use function to prevent the subprocess to receive KeyboardInterrupt

picar.filenames(alive, duration, cameraFreq, beginTime)

Filename generator: Used with Camera class to generate a series of filename for the picture to be stored at

Parameters:
  • alive – The global variable keeping the state of the program and processes
  • duration – Experiment duration
  • cameraFreq – Camera Frequency
  • beginTime – root directory as a timestamp
picar.getCamera(gen, alive, duration, cameraFreq, beginTime)

The filming function executed in a different core :param gen: the filenames generator :param alive: the global variable to track the state in the main function :param duration: the elapse time for the test :param cameraFreq: the cameraFrequncy in Hz :param beginTime: (string) the directory of the root folder for the logging files

picar.getSensor(alive, rowList, duration, precision, datafile, timers)

The data logging function executed in a different core :param alive: the global variable to track the state in the main function :param rowList: a list stores timestamp and logging data :param duration: the elapse time for the test :param precision: the gap between two visit of the script to sensors :param datafile: file name of the datafile :param timers: a list of timers holding sensors

picar.getSensorAndCamera(host='192.168.1.121', port=6000, save=False, duration=5, endless=False, trAccRate=6, trGyroRate=6, trMagRate=7, accScale=2, gyroScale=245, magScale=4, cameraFreq=5, imuRate=50, lidarRate=50, precision=0.001, tm=[])

A easy to use logging version supporting camera data logging, IMU reading, Lidar reading