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:40] – [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. | ||
<code cpp | StatusCheck.h> | <code cpp | StatusCheck.h> | ||
+ | //Line 16 | ||
enum { | enum { | ||
INITIAL, | INITIAL, | ||
Line 55: | Line 57: | ||
MOTION, | MOTION, | ||
VISION, | VISION, | ||
- | | + | |
MAX_MODE | MAX_MODE | ||
}; | }; | ||
</ | </ | ||
- | ==== Final Words ==== | ||
- | This tutorial' | + | <code cpp | StatusCheck.cpp> |
- | \\ | + | //At the end of if statement Line 141 |
- | \\ | + | if(m_old_btn & BTN_MODE) |
- | Speculating future work derived | + | /////////////////////////// |
+ | ////////////////////////// | ||
+ | ////////////////////////// | ||
+ | else if(m_cur_mode == SPRINT) //adding LED and play mp3 for new mode | ||
+ | { | ||
+ | cm730.WriteByte(CM730:: | ||
+ | //Signaling Darwin OP 2 which LED to turn on | ||
+ | LinuxActionScript:: | ||
+ | //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:: | ||
+ | MotionManager:: | ||
+ | // | ||
+ | m_is_started = 1; | ||
+ | LinuxActionScript:: | ||
+ | //play an mp3 file (you can use any mp3 file but make sure file name matches) | ||
+ | |||
+ | // Joint Enable... | ||
+ | Action:: | ||
+ | |||
+ | Action:: | ||
+ | while(Action:: | ||
+ | |||
+ | Head:: | ||
+ | Walking:: | ||
+ | // | ||
+ | | ||
+ | | ||
+ | { | ||
+ | if(MotionManager:: | ||
+ | { | ||
+ | LinuxActionScript:: | ||
+ | break; | ||
+ | } | ||
+ | else if(MotionManager:: | ||
+ | { | ||
+ | LinuxActionScript:: | ||
+ | MotionManager:: | ||
+ | } | ||
+ | usleep(8000); | ||
+ | } | ||
+ | //copied status check condition | ||
+ | //These codes initialize Darwin OP 2 for movement and walking | ||
+ | </code> | ||
+ | |||
+ | <code cpp | main.cpp> | ||
+ | //L317 Add | ||
+ | case New_Mode: | ||
+ | //implement new codes here to execute after pressing start button | ||
+ | </ | ||
+ | |||
+ | ===== Demonstration ===== | ||
+ | |||
+ | In this demonstration, I created a new mode called Sprint mode following | ||
+ | |||
+ | {{ youtube>WFf2_SOmUEI? | ||
+ | |||
+ | ===== Final Words ===== | ||
+ | |||
+ | This tutorial' | ||
\\ | \\ | ||
\\ | \\ | ||
- | For questions, clarifications, | + | For questions, clarifications, |
new_mode_demonstration.1511044844.txt.gz · Last modified: by yuhanghe