Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FiniteStateMachine HipControl Knee LinearBlend1 LocalFileSystem_Read dataComm hapticFeedback initExoVars mbed Blend_Generator Brad_poly_gait Gait_Generator MM_gait Encoders IMUdriver
Fork of Motion Control by
Diff: main.cpp
- Revision:
- 18:03d7c5fdc0c7
- Parent:
- 17:b77c31807825
- Child:
- 19:70b2124c7370
--- a/main.cpp Tue Mar 17 21:16:43 2015 +0000
+++ b/main.cpp Fri Mar 20 20:27:08 2015 +0000
@@ -15,19 +15,10 @@
#include "FSM.h"
#include "dataBedComm.h"
#include "dataComm.h"
-
-dataComm *dc = new dataComm();
-short int dataIn[32];
-short int dataOut[]= {0xFF,30,31,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xFE};
-bool flag=0;
-
-/*union short_or_char {
- char c[2];
- short s;
-} short_or_char;*/
-
-//short_or_char soc;
-
+short dataIn[7];
+short dataOut[]={0xFF,30,31,0, 0, 0, 0xFE};
+dataComm dc = dataComm();
+Timer dbg;
///////////////////////////////////////////////////////////////////////////
@@ -35,49 +26,43 @@
// It initiates communication with dataBed, checks for errors/safety, and starts the FSM
void periodicFcns()
{
- //pc.printf("Blah\r\n");
+ dbg.reset();
+ //float temp1 = dbg.read_us();
+
+ //dbg.start();
dataOut[1]=encoder_L.readRaw();
- dataOut[2]=fsm.error();
- int* ptr=(int*)dataIn;
- ptr=sendData((int*)dataOut, 21, (int*)dataIn);
- flag=1;
- /*for (int i=0;i<21;i++) {
+ //dataOut[2]=fsm.error();
+ short* ptr=dataIn;
+ ptr=sendData(dataOut, 7, dataIn);
+ //dbg.reset();
+ /*for (int i = 0; i < 7; i++) {
pc.printf("%x, ", dataIn[i]);
- }*/
- //pc.printf("\r\n");
- //dc->process_write((char*)dataIn,42);
-
- //dc->process_write(dataIn, 21);
-
+ }
+ pc.printf("\r\n");*/
+ dc.process_write(dataIn, 7);
//pc.printf("%d, %d, %d, %d,", dataIn[0], dataIn[1], dataIn[2], dataIn[3]);
-
+
// Run state change/analysis in FSM
int exoState=fsm.state(dataIn[1]);
-
+ float temp=dbg.read_us();
+ pc.printf("%f\r\n",temp);
+
}
int main()
{
pc.printf("\r\nExoStart \r\n");
initializeExoIOs();
- pc.printf("Test\r\n"); // keep for debugging compile errors
+ //pc.printf("Test\r\n"); // keep for debugging compile errors
pc.printf("Starting exo...\n\r");
//If desired, a startup sound can be played. This function is defined in the DatabedCode, because it will command a sound to be played once it detects a heartbeat from ControlBed
wait(2);
-
+ dbg.start();
Ticker doControl;
dataBedSPI.format(16,0);
doControl.attach(&periodicFcns, SAMPLE_TIME);
- while (1) {
- //pc.printf("!");
- if(flag==1) {
- flag=0;
- for (int i=0; i<21; i++) {
- pc.printf("%x, ", dataIn[i]);
- }
- }
- };
+ while (1);
}
