experiment with reverse
[201903hackathon.git] / cpp / openCVnaiveObstacleAvoidance / openCVnaiveObstacleAvoidance.cpp
index fe72e4c..c8b60a3 100644 (file)
@@ -58,6 +58,10 @@ class MyListener : public IDepthDataListener
     const string bobbycar_forward = "f";
     const string bobbycar_left = "l";
     const string bobbycar_right = "r";
+    const string bobbycar_backward = "b";
+
+    uint8_t bobbycar_reversing = 254;
+    royale::Vector<royale::String> boobycar_reversing_script ={"s","b","b","b","r","r","r","r","r","r","b","b"};
 
 public :
 
@@ -265,6 +269,12 @@ private:
 
     void naiveObstacleAvoidanceDemo()
     {
+        if (bobbycar_reversing<boobycar_reversing_script.size()) {
+            std::cout << boobycar_reversing_script.at(bobbycar_reversing++) << std::endl;
+            return;
+        }
+
+
         bool free_paths[num_dist_columns_];
         if (naiveIsObstaclePresent(free_paths))
         {
@@ -284,6 +294,7 @@ private:
             } else {
                 // std::cout << "STOP" << std::endl;
                 std::cout << bobbycar_stop << std::endl;
+                bobbycar_reversing = 0;
             }
         } else {
             std::cout << bobbycar_forward << std::endl;
@@ -334,7 +345,7 @@ int main (int argc, char *argv[])
         {
             // if no argument was given try to open the first connected camera
             royale::Vector<royale::String> camlist (manager.getConnectedCameraList());
-            cout << "Detected " << camlist.size() << " camera(s)." << endl;
+            //cout << "Detected " << camlist.size() << " camera(s)." << endl;
 
             if (!camlist.empty())
             {
@@ -404,7 +415,9 @@ int main (int argc, char *argv[])
 
 
     // set an operation mode
-    if (cameraDevice->setUseCase ("MODE_5_45FPS_500") != royale::CameraStatus::SUCCESS)
+    // if (cameraDevice->setUseCase ("MODE_5_45FPS_500") != royale::CameraStatus::SUCCESS)
+    // if (cameraDevice->setUseCase ("MODE_9_10FPS_1000") != royale::CameraStatus::SUCCESS)
+    if (cameraDevice->setUseCase ("MODE_9_5FPS_2000") != royale::CameraStatus::SUCCESS)
     {
         cerr << "Error setting use case" << endl;
         return 1;