![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
This is some awesome robot code
Dependencies: mbed-rtos mbed QEI
Fork of ICRSEurobot13 by
Diff: Actuators/Arms/Arm.h
- Revision:
- 65:4709ff6c753c
- Parent:
- 5:56a5fdd373c9
--- a/Actuators/Arms/Arm.h Sat Apr 13 22:42:01 2013 +0000 +++ b/Actuators/Arms/Arm.h Sun Apr 14 17:57:12 2013 +0000 @@ -1,69 +1,44 @@ - -// Eurobot13 WhiteArm.h +#ifndef EUROBOT_ACTUATORS_ARMS_ARM_H_ +#define EUROBOT_ACTUATORS_ARMS_ARM_H_ #include "mbed.h" -#include "Servo.h" -class Arm : public Servo +namespace arm { -private: - bool updirn; + +class Arm; +extern Arm lower_arm; +extern Arm upper_arm; + + +class Arm +{ public: - Arm ( PinName yellowPWM - , bool upflip = false - , float range = 0.0005, float degrees = 45.0 - ) - : Servo(yellowPWM) - { - calibrate(range, degrees); - updirn = upflip; + Arm (PwmOut pwm_in, float period_in, float min_pos_in, float max_pos_in) + : pwm_(pwm_in), period_(period_in), min_pos_(min_pos_in), max_pos_(max_pos_in) + { + pwm_.period(period_); } - void operator()(float in) { - write(in); - } - - void clockwise() { // full lock clockwise - write(updirn?1:0); - } - - void anticlockwise() { // full lock anticlockwise - write(updirn?0:1); + void go_up() + { + pwm_.pulsewidth_us(max_pos_*1000); } - virtual void halt() { // servo applies no force - //DigitalOut myled(LED3); - //myled = 1; - _pwm = 0; - } -}; - - -/* -class Servo{ - private: - PwmOut PWM; - - public: - Servo(PinName pin1) : PWM(pin1){ + void go_down() + { + pwm_.pulsewidth_us(min_pos_*1000); } - void operator()(float in){ - PWM = in; - } - - void clockwise() { // full lock clockwise - PWM = .135; - } - - void anticlockwise() { // full lock anticlockwise - PWM = .025; - } - - void relax() { // servo applies no force - PWM = 0; - } +private: + PwmOut pwm_; + float period_; + float min_pos_; + float max_pos_; }; -*/ \ No newline at end of file + +} //namespace + +#endif \ No newline at end of file