for ros integration

Dependencies:   wheelchaircontrolRos

Fork of wheelchaircontrolrealtime by ryan lin

Revision:
6:b8a1fa98707e
Parent:
5:186967c92ef5
Child:
7:cead0e7b0c1e
diff -r 186967c92ef5 -r b8a1fa98707e main.cpp
--- a/main.cpp	Mon Aug 13 21:53:21 2018 +0000
+++ b/main.cpp	Wed Aug 15 17:05:59 2018 +0000
@@ -28,7 +28,7 @@
 {
     if(command.linear.x >0) {
         c = 'w';
-        }
+    }
     received = true;
 }
 
@@ -44,11 +44,14 @@
 
 int main(void)
 {
+    on = 0;
+    off = 0;
+    
     queue.call_every(SAMPLEFREQ, &smart, &Wheelchair::compass_thread);
     t.reset();
     thread.start(callback(&queue, &EventQueue::dispatch_forever));
     setupNode();
-   while(1) {
+    while(1) {
         if( received) {
 
             if( c == 'w') {
@@ -91,6 +94,16 @@
                     smart.pid_turn(angle);
                 }
 
+            } else if(c == 'o') {
+                pc.printf("turning on\n");
+                on = 1;
+                wait(1);
+                on = 0;
+            } else if(c == 'f') {
+                pc.printf("turning off\n");
+                off = 1;
+                wait(1);
+                off = 0;
             }
 
             else if( c == 'm' || manual) {
@@ -119,7 +132,6 @@
             //        pc.printf("Nothing pressed \n");
             smart.stop();
         }
-        received = !received;
         wait(process);
     }
 
@@ -127,11 +139,6 @@
 
 
 
-/*
-void publishTwist(ros::Publisher* toChat) [
-    toChat->publish( &commandRead);
-    nh.spinOnce();
-}*/