Yusuke Aihara / CustomExplorerRobot

Dependents:   CustomExplorerRobot_test

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers CustomExplorerRobot.h Source File

CustomExplorerRobot.h

00001 /* mbed CustomExplorerRobot Library
00002  *
00003  * CustomExplorerRobot.h
00004  *
00005  * Copyright (c) 2016 ??????
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a copy
00008  * of this software and associated documentation files (the "Software"), to deal
00009  * in the Software without restriction, including without limitation the rights
00010  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
00011  * copies of the Software, and to permit persons to whom the Software is
00012  * furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included in
00015  * all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00018  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
00020  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00021  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
00022  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
00023  * THE SOFTWARE.
00024  */
00025 
00026 #ifndef CUSTOMEXPLORERROBOT_H
00027 #define CUSTOMEXPLORERROBOT_H
00028 
00029 #include "mbed.h"
00030 #include "BD6212.h"
00031 
00032 /** CustomExplorerRobot control class
00033  *
00034  * Example:
00035  * @code
00036  * // Drive the CustomExplorerRobot forward, turn left, back, turn right, at half speed for half a second
00037  
00038 #include "mbed.h"
00039 #include "CustomExplorerRobot.h"
00040 
00041 CustomExplorerRobot cer;
00042 
00043 int main() {
00044     
00045     wait(0.5f);
00046     cer.forward(0.5f);
00047     wait(0.5f);
00048     cer.left(0.5f);
00049     wait(0.5f);
00050     cer.backward(0.5f);
00051     wait(0.5f);
00052     cer.right(0.5f);
00053     wait(0.5f);
00054     cer.stop();
00055     
00056     return 0;
00057 }
00058  * @endcode
00059  */
00060 class CustomExplorerRobot{
00061     public:
00062     /** Create the CustomExplorerRobot object connected to the default pins
00063      */
00064     CustomExplorerRobot();
00065     
00066     /** Directly control the speed and direction of the left motor
00067      *
00068      * @param speed A normalised number -1.0 - 1.0 represents the full range.
00069      */
00070     void left_motor(float speed);
00071     
00072     /** Directly control the speed and direction of the right motor
00073      *
00074      * @param speed A normalised number -1.0 - 1.0 represents the full range.
00075      */
00076     void right_motor(float speed);
00077     
00078     /** Drive both motors forward as the same speed
00079      *
00080      * @param speed A normalised number 0 - 1.0 represents the full range.
00081      */
00082     void forward(float speed);
00083     
00084     /** Drive both motors backward as the same speed
00085      *
00086      * @param speed A normalised number 0 - 1.0 represents the full range.
00087      */
00088     void backward(float speed);
00089     
00090     /** Drive left motor backwards and right motor forwards at the same speed to turn on the spot
00091      *
00092      * @param speed A normalised number 0 - 1.0 represents the full range.
00093      */
00094     void left(float speed);
00095     
00096     /** Drive left motor forward and right motor backwards at the same speed to turn on the spot
00097      * @param speed A normalised number 0 - 1.0 represents the full range.
00098      */
00099     void right(float speed);
00100     
00101     /** Stop both motors
00102      *
00103      */
00104     void stop(void);
00105     
00106     protected:
00107     BD6212 _right;
00108     BD6212 _left;
00109     
00110     DigitalOut _redled;
00111     DigitalOut _blueled;
00112     
00113     PwmOut _buzzer;
00114     
00115 };
00116 
00117 #endif