Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: Motordriver mbed-rtos mbed
Fork of MultiModalRobotSM by
MultiModalRobot.cpp
00001 #include "MultiModalRobot.h" 00002 00003 MultiModalRobot::MultiModalRobot(Motor& left, Motor& right) : leftWheel(left), rightWheel(right), leftDir(0), rightDir(0) {} 00004 00005 00006 00007 void MultiModalRobot::driveWheels(float leftSpeed, float rightSpeed){ 00008 if(leftSpeed*leftDir<0 || rightSpeed*rightDir<0){ 00009 stop(0.5); 00010 } 00011 if(leftSpeed<0){ 00012 leftDir = -1; 00013 } else { 00014 leftDir = 1; 00015 } 00016 if(rightSpeed<0){ 00017 rightDir = -1; 00018 } else { 00019 rightDir = 1; 00020 } 00021 leftWheel.speed(leftSpeed); 00022 rightWheel.speed(rightSpeed); 00023 wait(0.1); 00024 stop(0.5); 00025 } 00026 00027 void MultiModalRobot::stop(float dutyCycle){ 00028 leftDir = rightDir = 0; 00029 leftWheel.coast(); 00030 rightWheel.coast(); 00031 }
Generated on Sun Jul 24 2022 08:59:13 by
1.7.2
