Stinger Robot Library

Table of Contents

  1. API
  2. Hello World

This is a test library to Control Stinger Robot. PID QEI libraries are implemented inside, so all you have to do is give Robot simple commands. This library was designed simplify operation of Stinger robot only with MBED and two H-Bridges.

General idea is to create a library that will free up programmer from worrying about what robot does and to provide several functions that will move robot and allow user execute other code during robot movements.

It is still in development.

Class Robot integrated QEI, PID and Motor classes to work together through use of Ticker function to regularly poll QEI objects, adjust PID and Motor objects.

Right now all pins have been preassigned, later empty constructor will be added with individual pin assignments. /media/uploads/gtg795y/_scaled_robot.jpg

Pinouts are:

rightMotor = new Motor(p23, p6, p5); pwm, fwd, rev

leftMotor = new Motor(p22, p8, p7); pwm, fwd, rev

leftQei = new QEI(p29, p30, NC, 624, QEI::X2_ENCODING); chanA, chanB, index, ppr

rightQei = new QEI(p27, p28, NC, 624, QEI::X2_ENCODING); chanB, chanA, index, ppr

leftPid = new PID(0.4312, 0.1, 0.0, RATE); Kc, Ti, Td

rightPid = new PID(0.4312, 0.1, 0.0, RATE); Kc, Ti, Td


Import libraryRobot

No documentation found.

Hello World

#include  "mbed.h"
#include  "QEI.h"
#include  "Motor.h"
#include  "PID.h"
#include  "Robot.h"

Robot robot;

int main() {
        robot.MoveStraightInches(0.9,100);  // Move forward 100 inches at speed 0.9 (-1.0 to 1.0)
        while (robot.IsBusy()) {
            // Code can be run while robot is moving
        robot.MoveStraightInches(-0.9,100); // Move back 100 inches at speed 0.9 (-1.0 to 1.0)
        while (robot.IsBusy()) {}
        robot.PivetLeft(180);               // Turn left 180 degrees
        while (robot.IsBusy()) {}
        robot.PivetRight(90);               // Turn right 90 degrees
        while (robot.IsBusy()) {}

All wikipages