Code for the COVR project DROPSAW project test rig (previously used for the Heros testing).

Dependencies:   SPTE_10Bar_5V mbed AS5048 SDFileSystem MODSERIAL LCM101_DROPSAW LinearActuator

Revision:
6:02507d7a6f51
Parent:
5:63063a9fa51c
Child:
7:edb876c98565
--- a/bench.cpp	Mon Dec 09 10:51:46 2019 +0000
+++ b/bench.cpp	Mon Dec 09 11:15:47 2019 +0000
@@ -147,6 +147,10 @@
     
 }
 
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+// IMPLEMENTATION HARDWARE INTERFACE
+// = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
+
 /**
  * Update routine for the testbench.
  * - Updates the angle buffer of the sensor array
@@ -159,6 +163,25 @@
     as5048_.UpdateAngleBuffer();
 }
 
+/**
+ * Obtain the joint angle in degrees.
+ * These are the angles at the time of two Update() calls back
+ * @param joint: the joint for which the angle is requested (as enumerated in 
+ * class header - TOES, KNEE, ANKLE, HIP
+ * @return: joint angle
+ */
+float Bench::getDegrees(Joint joint) 
+{
+    return getDegrees(joint);
+}
+
+/**
+ * Obtain the joint angle in degrees.
+ * These are the angles at the time of two Update() calls back
+ * @param joint: the joint for which the angle is requested (a number starting 
+ * from 0 indicating the position in the sensor daisy chain)
+ * @return: joint angle
+ */
 float Bench::getDegrees(int i_joint) 
 {
     float ang = as5048_.getAngleDegrees(i_joint);
@@ -168,6 +191,115 @@
     return ang;
 }
 
+/**
+ * Obtain the joint angle in radians.
+ * These are the angles at the time of two Update() calls back
+ * @param joint: the joint for which the angle is requested (as enumerated in 
+ * class header - TOES, KNEE, ANKLE, HIP
+ * @return: joint angle
+ */
+float Bench::getRadians(Joint joint) 
+{
+    return getRadians(joint);
+}
+
+/**
+ * Obtain the joint angle in radians.
+ * These are the angles at the time of two Update() calls back
+ * @param joint: the joint for which the angle is requested (a number starting 
+ * from 0 indicating the position in the sensor daisy chain)
+ * @return: joint angle
+ */
+float Bench::getRadians(int i_joint) 
+{
+    float ang = as5048_.getAngleRadians(i_joint);
+    if (ang>kCutOffRadians) {
+        return ang-As5048::kRadPerRev;
+    }
+    return ang;
+}
+
+
+const char* Bench::getJointName(int i_joint) 
+{
+    return sensors::kJointNames[i_joint];
+}
+
+const char* Bench::getJointName(Joint joint) 
+{
+    return getJointName(joint);
+}
+
+As5048* Bench::get_as5048() 
+{
+    return &as5048_;
+}
+
+/**
+ * The force applied vertically at the hip join in N.
+ * @return: force
+ */
+float Bench::getForce() 
+{
+    if (Bench::use5kN) {
+        return loadCell5kN.getForce();
+    } else {
+        return loadCell1kN.getForce();
+    }
+    
+}
+
+void Bench::nullForce()
+{
+    if (use5kN) {
+        return loadCell5kN.nullForce();
+    } else {
+        return loadCell1kN.nullForce();
+    }
+}
+
+/**
+ * The pressure measured by pressure sensor 0 in bar
+ * @return: pressure
+ */
+float Bench::getPressure0() 
+{
+    return spte0.getPressure();
+}
+
+void Bench::nullPressure0()
+{
+    return spte0.nullPressure();
+}
+
+float Bench::getPressure1() 
+{
+    return spte1.getPressure();
+}
+
+void Bench::nullPressure1()
+{
+    return spte1.nullPressure();
+}
+
+/**
+ * Control the valve (true turns the valve on to pressurise, false turns 
+ * the valve off to depressurise)
+ * @param set: valve state
+ */
+void Bench::setValve(bool set)
+{
+    valveFesto.setValve(set);
+}
+
+/**
+ * The valve state (true is on/pressurising and false is off/depressurising)
+ * @return: valve state
+ */
+bool Bench::getValve() {
+    return valveFesto.getValve();   
+}
+
 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 // IMPLEMENTATION DATA LOGGING
 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
@@ -213,6 +345,8 @@
 
 /**
  * Start logging data
+ * param fname_append: a string describing the name appended to each logged file
+ * (along with its unique loggging number)
  */
 void Bench::StartLogging(const char * fname_append)
 {    
@@ -380,7 +514,7 @@
 // = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =
 
 /**
- * button lower toggles printing of data
+ * SW2 toggles printing of data
  */
 void Bench::TogglePrinting()
 {
@@ -394,7 +528,7 @@
 }
 
 /*
- * button lower toggles printing of data
+ * SW3 toggles logging of data
  */
 void Bench::ToggleLogging()
 {
@@ -409,103 +543,10 @@
 
 /*
  * Indicates if we are now data logging
+ * return: true if logging
  */
 bool Bench::isLogging()
 {
     return is_logging;
 }
     
-/**
- * Obtain the joint angle in degrees.
- * These are the angles at the time of two Update() calls back
- * @param joint: the joint for which the angle is requested
- * @return: joint angle
- */
-float Bench::getDegrees(Joint joint) 
-{
-    return getDegrees(joint);
-}
-
-float Bench::getRadians(int i_joint) 
-{
-    float ang = as5048_.getAngleRadians(i_joint);
-    if (ang>kCutOffRadians) {
-        return ang-As5048::kRadPerRev;
-    }
-    return ang;
-}
-
-/**
- * Obtain the joint angle in radians.
- * These are the angles at the time of two Update() calls back
- * @param joint: the joint for which the angle is requested
- * @return: joint angle
- */
-float Bench::getRadians(Joint joint) 
-{
-    return getRadians(joint);
-}
-
-
-const char* Bench::getJointName(int i_joint) 
-{
-    return sensors::kJointNames[i_joint];
-}
-
-const char* Bench::getJointName(Joint joint) 
-{
-    return getJointName(joint);
-}
-
-As5048* Bench::get_as5048() 
-{
-    return &as5048_;
-}
-
-float Bench::getForce() 
-{
-    if (Bench::use5kN) {
-        return loadCell5kN.getForce();
-    } else {
-        return loadCell1kN.getForce();
-    }
-    
-}
-
-void Bench::nullForce()
-{
-    if (use5kN) {
-        return loadCell5kN.nullForce();
-    } else {
-        return loadCell1kN.nullForce();
-    }
-}
-
-float Bench::getPressure0() 
-{
-    return spte0.getPressure();
-}
-
-void Bench::nullPressure0()
-{
-    return spte0.nullPressure();
-}
-
-float Bench::getPressure1() 
-{
-    return spte1.getPressure();
-}
-
-void Bench::nullPressure1()
-{
-    return spte1.nullPressure();
-}
-
-void Bench::setValve(bool set)
-{
-    valveFesto.setValve(set);
-}
-
-bool Bench::getValve() {
-    return valveFesto.getValve();   
-}
\ No newline at end of file