This is an old revision of the document!
How To Add a New Mode to Darwin OP 2
Author: Yu Hang He Email: hey6@unlv.nevada.edu
Date: Last modified on <11/18/17>
Keywords: Darwin OP 2, C/C Programming, New Mode
\\
\\
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.
\\
===== Motivation and Audience =====
This tutorial's motivation is to demonstrate a process to quickly implement and test new codes on Darwin OP 2. This tutorial assumes the reader has the following background and interests:
<fc blue>
* Familiar with handling Darwin OP 2
\\
* Familiar with C++/C programming language
\\
* Familiar with C++/C codes on Darwin OP 2
\\
</fc>
\\
The rest of this tutorial is presented as follows:
* [[new_mode_demonstration#Source_Code
- | StatusCheck.h
//Line 16 enum { INITIAL, READY, SOCCER, MOTION, VISION, SPRINT, //Add a new mode called "SPRINT" to an enumerated list of modes MAX_MODE };
- | StatusCheck.cpp
if(m_old_btn & BTN_MODE) { fprintf(stderr, "Mode button pressed.. \n"); if(m_is_started != 0) { m_is_started = 0; m_cur_mode = READY; if(LinuxActionScript::m_is_running) LinuxActionScript::m_stop = 1; Walking::GetInstance()->Stop(); Action::GetInstance()->m_Joint.SetEnableBody(true, true); while(Action::GetInstance()->Start(15) == false) usleep(8000); while(Action::GetInstance()->IsRunning() == true) usleep(8000); } else { m_cur_mode++; if(m_cur_mode >= MAX_MODE) m_cur_mode = READY; } MotionManager::GetInstance()->SetEnable(false); usleep(10000); if(m_cur_mode == READY) { cm730.WriteByte(CM730::P_LED_PANNEL, 0x01|0x02|0x04, NULL); LinuxActionScript::PlayMP3("../../../Data/mp3/Demonstration ready mode.mp3"); } else if(m_cur_mode == SOCCER) { cm730.WriteByte(CM730::P_LED_PANNEL, 0x01, NULL); LinuxActionScript::PlayMP3("../../../Data/mp3/Autonomous soccer mode.mp3"); } else if(m_cur_mode == MOTION) { cm730.WriteByte(CM730::P_LED_PANNEL, 0x02, NULL); LinuxActionScript::PlayMP3("../../../Data/mp3/Interactive motion mode.mp3"); } else if(m_cur_mode == VISION) { cm730.WriteByte(CM730::P_LED_PANNEL, 0x04, NULL); LinuxActionScript::PlayMP3("../../../Data/mp3/Vision processing mode.mp3"); } else if(m_cur_mode == SPRINT) //adding LED and play mp3 for Sprint mode { cm730.WriteByte(CM730::P_LED_PANNEL, 0x01|0x04, NULL); LinuxActionScript::PlayMP3("../../../Data/mp3/Sprint mode.mp3"); } }
==== Final Words ====
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>.
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.
For questions, clarifications, etc, Email: paul.oh@unlv.edu