User Tools

Site Tools


new_mode_demonstration

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
new_mode_demonstration [2017/11/18 14:47] yuhanghenew_mode_demonstration [2017/11/19 13:08] (current) – [Motivation and Audience] yuhanghe
Line 1: Line 1:
-====== How To Add a New Mode to Darwin OP 2 ======+====== How to Add a New Mode to Darwin OP 2 ======
  
  
Line 6: Line 6:
 **Date:** Last modified on <11/18/17> **Date:** Last modified on <11/18/17>
 \\ \\
-**Keywords:** Darwin OP 2, C++/C Programming, New Mode +**Keywords:** Darwin OP 2, C++/C Programming, Robotis OP 2
 \\ \\
  
 \\ \\
-This tutorial will demonstrate how to add a new mode to Darwin OP 2's demo program. The new mode will be added alongside Autonomous Soccer, Interactive Motion, and Vision Processing mode. After starting program, use mode button on the back of Darwin OP 2 to cycle through modes and press start button to start the new mode.It takes approximately 1 hour to complete. +This tutorial will demonstrate how to add a new mode to Darwin OP 2's demo program. The new mode will be added alongside Autonomous Soccer, Interactive Motion, and Vision Processing mode. After starting program, use mode button on the back of Darwin OP 2 to cycle through modes and press start button to start the new mode.It takes approximately 2 hours to complete. 
 \\ \\
 ===== Motivation and Audience ===== ===== Motivation and Audience =====
Line 29: Line 29:
   * [[new_mode_demonstration#Source_Code | Source_Code]]   * [[new_mode_demonstration#Source_Code | Source_Code]]
   * [[new_mode_demonstration#Programming | Programming]]   * [[new_mode_demonstration#Programming | Programming]]
 +  * [[new_mode_demonstration#Demonstration | Demonstration]]
   * [[new_mode_demonstration#Final_Words | Final Words]]   * [[new_mode_demonstration#Final_Words | Final Words]]
  
-==== Source Code ====+===== Source Code =====
  
 It is always recommended to modify a copy of Darwin OP's source code instead of editing the source code directly.  It is always recommended to modify a copy of Darwin OP's source code instead of editing the source code directly. 
Line 44: Line 45:
 \\ \\
 ''**main.cpp**'', ''**StatusCheck.cpp**'', and ''**StatusCheck.h**'' will be modified to implement the new mode. ''**main.cpp**'', ''**StatusCheck.cpp**'', and ''**StatusCheck.h**'' will be modified to implement the new mode.
-==== Programming ====+===== Programming =====
  
 This tutorial will only demonstrate parts of program that needs modification to include a new mode. This tutorial will only demonstrate parts of program that needs modification to include a new mode.
Line 56: Line 57:
         MOTION,         MOTION,
         VISION,         VISION,
-        SPRINT, //Add a new mode called "SPRINT" to an enumerated list of modes+        NEW_MODE, //Add a new mode called "NEW_MODE" to an enumerated list of modes
         MAX_MODE         MAX_MODE
     };     };
Line 62: Line 63:
  
 <code cpp | StatusCheck.cpp> <code cpp | StatusCheck.cpp>
 +//At the end of if statement Line 141
 +if(m_old_btn & BTN_MODE)
 +        ///////////////////////////
 +        //////////////////////////
 +        //////////////////////////
 +        else if(m_cur_mode == SPRINT) //adding LED and play mp3 for new mode
 +        {
 +            cm730.WriteByte(CM730::P_LED_PANNEL, 0x01|0x04, NULL);
 +            //Signaling Darwin OP 2 which LED to turn on
 +            LinuxActionScript::PlayMP3("../../../Data/mp3/New_Mode mode.mp3");
 +            //play an mp3 file (you can use any mp3 file but make sure file name matches)
 +        }
 +    }
 +    
 +// Line 267 Add
 +  else if(m_cur_mode == NEW_MODE)
 +  {
 +      MotionManager::GetInstance()->Reinitialize();
 +      MotionManager::GetInstance()->SetEnable(true);
 +      //initialize and enable MotionManager class
 +      m_is_started = 1;
 +      LinuxActionScript::PlayMP3("../../../Data/mp3/Start New_Mode demonstration.mp3");
 +      //play an mp3 file (you can use any mp3 file but make sure file name matches)
  
 +      // Joint Enable...
 +      Action::GetInstance()->m_Joint.SetEnableBody(true, true);
 +
 +      Action::GetInstance()->Start(9);
 +      while(Action::GetInstance()->IsRunning() == true) usleep(8000);
 +
 +      Head::GetInstance()->m_Joint.SetEnableHeadOnly(true, true);
 +      Walking::GetInstance()->m_Joint.SetEnableBodyWithoutHead(true, true);
 +      //Reset Gyro sensor
 +      MotionManager::GetInstance()->ResetGyroCalibration();
 +      while(1)
 +      {
 +          if(MotionManager::GetInstance()->GetCalibrationStatus() == 1)
 +          {
 +              LinuxActionScript::PlayMP3("../../../Data/mp3/Sensor calibration complete.mp3");
 +              break;
 +          }
 +          else if(MotionManager::GetInstance()->GetCalibrationStatus() == -1)
 +          {
 +              LinuxActionScript::PlayMP3Wait("../../../Data/mp3/Sensor calibration fail.mp3");
 +              MotionManager::GetInstance()->ResetGyroCalibration();
 +          }
 +          usleep(8000);
 +      }
 +  //copied status check condition from soccer mode to new mode
 +  //These codes initialize Darwin OP 2 for movement and walking
 </code> </code>
  
-==== Final Words ====+<code cpp | main.cpp> 
 +//L317 Add 
 +  case New_Mode: 
 +  //implement new codes here to execute after pressing start button 
 +</code>
  
-This tutorial's objective was to <fill in the blank>. Complete <choose: construction details, source code and program descriptions> for <fill in the blank>Once the concepts were conveyed the reader could <fill in the blank>+===== Demonstration ===== 
-\\ + 
-\\ +In this demonstration, I created a new mode called Sprint mode following the previous step and successfully execute it on Darwin OP 2. 
-Speculating future work derived from this tutorial, includes <fill in the blank>. In the big picture, the problem of <fill in the blank> can be solved with this tutorial.+ 
 +{{ youtube>WFf2_SOmUEI?large }}  
 + 
 +===== Final Words ===== 
 + 
 +This tutorial's objective was to demonstrate how to add a new mode to Darwin OP 2's demo program. Follow this tutorial to quickly implement and test new codes on Darwin OP 2.
 \\ \\
 \\ \\
-For questions, clarifications, etc, Email: <paul.oh@unlv.edu> +For questions, clarifications, etc, Email: <hey6@unlv.nevada.edu> 
  
  
new_mode_demonstration.1511045222.txt.gz · Last modified: by yuhanghe