new_mode_demonstration
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
new_mode_demonstration [2017/11/18 14:47] – [Programming] yuhanghe | new_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 < | **Date:** Last modified on < | ||
\\ | \\ | ||
- | **Keywords: | + | **Keywords: |
\\ | \\ | ||
\\ | \\ | ||
- | 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 | + | 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 |
\\ | \\ | ||
===== Motivation and Audience ===== | ===== Motivation and Audience ===== | ||
Line 29: | Line 29: | ||
* [[new_mode_demonstration# | * [[new_mode_demonstration# | ||
* [[new_mode_demonstration# | * [[new_mode_demonstration# | ||
+ | * [[new_mode_demonstration# | ||
* [[new_mode_demonstration# | * [[new_mode_demonstration# | ||
- | ==== 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: | ||
\\ | \\ | ||
'' | '' | ||
- | ==== 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, | ||
- | | + | |
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) | if(m_old_btn & BTN_MODE) | ||
- | { | + | /////////////////////////// |
- | | + | |
- | + | ////////////////////////// | |
- | if(m_is_started != 0) | + | |
{ | { | ||
- | | + | |
- | | + | |
- | if(LinuxActionScript::m_is_running) | + | LinuxActionScript:: |
- | | + | |
+ | } | ||
+ | } | ||
+ | |||
+ | // Line 267 Add | ||
+ | else if(m_cur_mode == NEW_MODE) | ||
+ | { | ||
+ | MotionManager::GetInstance()-> | ||
+ | | ||
+ | // | ||
+ | m_is_started | ||
+ | LinuxActionScript:: | ||
+ | //play an mp3 file (you can use any mp3 file but make sure file name matches) | ||
- | Walking:: | + | // Joint Enable... |
- | Action:: | + | Action:: |
- | while(Action:: | + | |
- | while(Action:: | + | while(Action:: |
- | } | + | |
- | else | + | |
- | { | + | |
- | m_cur_mode++; | + | |
- | if(m_cur_mode >= MAX_MODE) m_cur_mode = READY; | + | |
- | } | + | |
- | | + | Head:: |
- | usleep(10000); | + | Walking:: |
+ | //Reset Gyro sensor | ||
+ | | ||
+ | | ||
+ | { | ||
+ | if(MotionManager:: | ||
+ | { | ||
+ | LinuxActionScript:: | ||
+ | break; | ||
+ | } | ||
+ | else if(MotionManager:: | ||
+ | { | ||
+ | LinuxActionScript:: | ||
+ | MotionManager:: | ||
+ | } | ||
+ | | ||
+ | } | ||
+ | //copied status check condition from soccer mode to new mode | ||
+ | //These codes initialize Darwin OP 2 for movement and walking | ||
+ | </ | ||
- | if(m_cur_mode == READY) | + | <code cpp | main.cpp> |
- | { | + | //L317 Add |
- | cm730.WriteByte(CM730:: | + | case New_Mode: |
- | LinuxActionScript:: | + | //implement new codes here to execute after pressing start button |
- | } | + | |
- | else if(m_cur_mode == SOCCER) | + | |
- | { | + | |
- | cm730.WriteByte(CM730:: | + | |
- | LinuxActionScript:: | + | |
- | } | + | |
- | else if(m_cur_mode == MOTION) | + | |
- | { | + | |
- | cm730.WriteByte(CM730:: | + | |
- | | + | |
- | } | + | |
- | else if(m_cur_mode == VISION) | + | |
- | { | + | |
- | cm730.WriteByte(CM730:: | + | |
- | LinuxActionScript:: | + | |
- | } | + | |
- | else if(m_cur_mode == SPRINT) //adding LED and play mp3 for Sprint mode | + | |
- | { | + | |
- | cm730.WriteByte(CM730:: | + | |
- | LinuxActionScript:: | + | |
- | } | + | |
- | } | + | |
</ | </ | ||
- | ==== Final Words ==== | + | ===== Demonstration ===== |
- | This tutorial' | + | In this demonstration, |
- | \\ | + | |
- | \\ | + | {{ youtube> |
- | 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. | + | |
+ | ===== Final Words ===== | ||
+ | |||
+ | This tutorial' | ||
\\ | \\ | ||
\\ | \\ | ||
- | For questions, clarifications, | + | For questions, clarifications, |
new_mode_demonstration.1511045241.txt.gz · Last modified: by yuhanghe