Suraj Giri / Mbed 2 deprecated heros_leg_readout_torque_addition_V3

Dependencies:   SPTE_10Bar_5V mbed AS5048 SDFileSystem MODSERIAL PinDetect LCM101 LinearActuator

Embed: (wiki syntax)

« Back to documentation index

Bench Class Reference

Bench Class Reference

Class to read out sensory information from the second test bench: the knee joint angle as measured by an AMS AS5048 absolute rotary sensor the vertical force applied externally at the hip joint the pressure (for example of an actuator used in the device under test). More...

#include <bench.h>

Public Member Functions

 Bench (PinName mosi=AS5048_MOSI, PinName miso=AS5048_MISO, PinName sck=AS5048_SCLK, PinName cs=AS5048_CS, bool use5kN=sensors::use5kN, PinName p_lcm101=LCM101, PinName p_spte0=SPTE_0, PinName p_spte1=SPTE_1, PinName p_valve=VALVE_PIN, PinName p_laDir=LINACT_DIR_PIN, PinName p_laPwm=LINACT_PWM_PIN, PinName sd_mosi=SD_MOSI, PinName sd_miso=SD_MISO, PinName sd_sck=SD_SCK, PinName sd_cs=SD_CS, PinName tx=USBTX, PinName rx=USBRX)
 Create an object representing the test rig.
void initialise ()
 Initialises: timers, SD card Prints a welcome message and information on the logging frequency and sensor reading rate.
void setLoggingFrequency (float logHertz)
 Sets the rate at which data is logged in an experiment.
void setExtraColumns (string extraColumnNames[], int numCols)
 Sets names of extra columns of data to be recorded.
void setExtraData (float data[])
 Sets values of extra columns of data to be recorded.
void update ()
 Update routine for the test rig

  • Updates the angle buffer of the sensor array
  • ...

bool isLogging ()
 Indicates if we are now data logging.
void stopLogging ()
 Stop logging data and print the menu.
void StopLogging ()
 Stop logging data.
void StartLogging (const char *fname_append="data")
 Start logging data param fname_append: a string describing the name appended to each logged file (along with its unique loggging number).
void RestartLogging (const char *fname_append="data")
 Restart logging data (opens data logging file)
void LogData ()
 Log data.
float getDegrees (int i_joint)
 Obtain the joint angle in degrees These are the angles at the time of two Update() calls back.
float getDegrees (Joint joint)
 Obtain the joint angle in degrees These are the angles at the time of two Update() calls back.
float getRadians (int i_joint)
 Obtain the joint angle in radians These are the angles at the time of two Update() calls back.
float getRadians (Joint joint)
 Obtain the joint angle in radians These are the angles at the time of two Update() calls back.
float getForce ()
 The force applied vertically at the hip joint in N.
float getPressure0 ()
 The pressure measured by pressure sensor 0 in bar.
bool getValve ()
 The valve state (true is on/pressurising and false is off/depressurising).
void setValve (bool pressurise)
 Control the valve (true turns the valve on to pressurise, false turns the valve off to depressurise)
void setDir (bool dir)
 Control the linear actuator direction (true retracts and false extends)
bool getDir ()
 The linear actuator state (true is retracting and false is extending)
void setPWM (int pwm)
 Control the linear actuator speed (0-100% integer of pwm.
void pausePrint ()
 Stops the Bench class from printing data if it is.
void resumePrint ()
 Resumes printing in the Bench class.

Data Fields

MODSERIAL pc
 Object for printing/receiving data to the PC the test rig is connected to.

Detailed Description

Class to read out sensory information from the second test bench: the knee joint angle as measured by an AMS AS5048 absolute rotary sensor the vertical force applied externally at the hip joint the pressure (for example of an actuator used in the device under test).

Additionally, an on /off valve can pressurise the actuator on the leg

Definition at line 24 of file bench.h.


Constructor & Destructor Documentation

Bench ( PinName  mosi = AS5048_MOSI,
PinName  miso = AS5048_MISO,
PinName  sck = AS5048_SCLK,
PinName  cs = AS5048_CS,
bool  use5kNLoadCell = sensors::use5kN,
PinName  p_lcm101 = LCM101,
PinName  p_spte0 = SPTE_0,
PinName  p_spte1 = SPTE_1,
PinName  p_valve = VALVE_PIN,
PinName  p_laDir = LINACT_DIR_PIN,
PinName  p_laPwm = LINACT_PWM_PIN,
PinName  sd_mosi = SD_MOSI,
PinName  sd_miso = SD_MISO,
PinName  sd_sck = SD_SCK,
PinName  sd_cs = SD_CS,
PinName  tx = USBTX,
PinName  rx = USBRX 
)

Create an object representing the test rig.

Parameters:
mosi,:mosi pin for sensor chain (SPI angle sensors)
miso,:miso pin for sensor chain (SPI angle sensors)
sck,:clock pin for sensor chain (SPI angle sensors)
cs,:chip select pin for sensor chain (SPI angle sensors)
use5kNLoadCell,:if 5kN load cell is used (if false, 1kN sensor is used)
p_lcm101,:analog input pin for load cell
p_spte0,:analog input pin for pressure sensor 0
p_spte1,:analog input pin for pressure sensor 1
p_valve,:digital output for valve (on/off) that inflates leg actuator
p_laDir,:digital output for linear actuator direction (retract/extend)
p_laPwm,:pwm output for linear actuator speed
mosi,:mosi pin for sd card
miso,:miso pin for sd card
sck,:clock pin for sd card
cs,:chip select pin for sd card
tx,:serial transmission line
rx,:serial receive line

Definition at line 23 of file bench.cpp.


Member Function Documentation

float getDegrees ( int  i_joint )

Obtain the joint angle in degrees These are the angles at the time of two Update() calls back.

Parameters:
joint,:the joint for which the angle is requested (a number starting from 0 indicating the position in the sensor daisy chain)
Returns:
: joint angle

Definition at line 182 of file bench.cpp.

float getDegrees ( Joint  joint )

Obtain the joint angle in degrees These are the angles at the time of two Update() calls back.

Parameters:
joint,:the joint for which the angle is requested (as enumerated in class header - TOES, KNEE, ANKLE, HIP
Returns:
: joint angle

Definition at line 170 of file bench.cpp.

bool getDir (  )

The linear actuator state (true is retracting and false is extending)

Returns:
: linear actuator state

Definition at line 304 of file bench.cpp.

float getForce (  )

The force applied vertically at the hip joint in N.

Returns:
: force

Definition at line 239 of file bench.cpp.

float getPressure0 (  )

The pressure measured by pressure sensor 0 in bar.

Returns:
: pressure

Definition at line 262 of file bench.cpp.

float getRadians ( Joint  joint )

Obtain the joint angle in radians These are the angles at the time of two Update() calls back.

Parameters:
joint,:the joint for which the angle is requested (as enumerated in class header - TOES, KNEE, ANKLE, HIP
Returns:
: joint angle

Definition at line 198 of file bench.cpp.

float getRadians ( int  i_joint )

Obtain the joint angle in radians These are the angles at the time of two Update() calls back.

Parameters:
joint,:the joint for which the angle is requested (a number starting from 0 indicating the position in the sensor daisy chain)
Returns:
: joint angle

Definition at line 210 of file bench.cpp.

bool getValve (  )

The valve state (true is on/pressurising and false is off/depressurising).

Returns:
: valve state

Definition at line 296 of file bench.cpp.

void initialise (  )

Initialises: timers, SD card Prints a welcome message and information on the logging frequency and sensor reading rate.

Definition at line 70 of file bench.cpp.

bool isLogging (  )

Indicates if we are now data logging.

Returns:
: true if logging

Definition at line 633 of file bench.cpp.

void LogData (  )

Log data.

Definition at line 484 of file bench.cpp.

void pausePrint (  )

Stops the Bench class from printing data if it is.

Definition at line 554 of file bench.cpp.

void RestartLogging ( const char *  fname_append = "data" )

Restart logging data (opens data logging file)

Parameters:
fname_append,:a string describing the name appended to each logged file (along with its unique loggging number).

Definition at line 420 of file bench.cpp.

void resumePrint (  )

Resumes printing in the Bench class.

Definition at line 563 of file bench.cpp.

void setDir ( bool  dir )

Control the linear actuator direction (true retracts and false extends)

Parameters:
set,:direction

Definition at line 312 of file bench.cpp.

void setExtraColumns ( string  extraColumnNames[],
int  numCols 
)

Sets names of extra columns of data to be recorded.

Parameters:
extraColumnNames,:string array of the column names
numCols,:number of elements in the string array

Definition at line 118 of file bench.cpp.

void setExtraData ( float  data[] )

Sets values of extra columns of data to be recorded.

Parameters:
data,:data to be logged with the extra columns

Definition at line 138 of file bench.cpp.

void setLoggingFrequency ( float  hertz )

Sets the rate at which data is logged in an experiment.

Parameters:
hertz,:logging frequency in Hz

Definition at line 101 of file bench.cpp.

void setPWM ( int  pwm )

Control the linear actuator speed (0-100% integer of pwm.

generally need above 50% to get it moving)

Parameters:
pwm,:pwm duty cycle percentage

Definition at line 322 of file bench.cpp.

void setValve ( bool  set )

Control the valve (true turns the valve on to pressurise, false turns the valve off to depressurise)

Parameters:
set,:valve state

Definition at line 287 of file bench.cpp.

void StartLogging ( const char *  fname_append = "data" )

Start logging data param fname_append: a string describing the name appended to each logged file (along with its unique loggging number).

Definition at line 374 of file bench.cpp.

void StopLogging (  )

Stop logging data.

Definition at line 452 of file bench.cpp.

void stopLogging (  )

Stop logging data and print the menu.

Definition at line 472 of file bench.cpp.

void update (  )

Update routine for the test rig

  • Updates the angle buffer of the sensor array
  • ...

that's it for now (add filtering?) Note that angles lag one update() behind, due to the way the SPI protocol works.

Definition at line 158 of file bench.cpp.


Field Documentation

MODSERIAL pc

Object for printing/receiving data to the PC the test rig is connected to.

Note that it uses the MODSERIAL.h class.

Definition at line 102 of file bench.h.