Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   C++ Help with driving the robot forward (http://www.chiefdelphi.com/forums/showthread.php?t=125618)

GearTech 01-02-2014 14:53

C++ Help with driving the robot forward
 
Hello, we are of team 108. We are having some problems with our robot/code. In the code, we tell the robot to drive using the myRobot.TankDrive() function (We're driving in autonomous. We're not worrying about Teleop yet).
We have the robot using 4 Jaguars to connect to 4 motors. The Jaguars are connected to the Digital Side Car in this way:
Front Left motor: PWM 6
Rear Left motor: PWM 5
Front Right motor: PWM 2
Rear Right motor: PWM 1


Code:

#include "WPILib.h"
#include "DriverStationLCD.h"

/**
 * This is a demo program showing the use of the RobotBase class.
 * The SimpleRobot class is the base of a robot application that will automatically call your
 * Autonomous and OperatorControl methods at the right time as controlled by the switches on
 * the driver station or the field controls.
 */

class RobotDemo : public SimpleRobot
{
        RobotDrive myRobot; // robot drive system
        Jaguar FR, FL, RR, RL;
        Joystick stick; // only joystick
        DriverStationLCD * screen;
        Watchdog Spot;
public:
        RobotDemo():
                FL(6), RL(5), FR(2), RR(1),
                myRobot(FL, RL, FR, RR),        // these must be initialized in the same order
                stick(1)                // as they are declared above.
        {
                Spot.SetEnabled(false);
                screen = DriverStationLCD::GetInstance();
//                myRobot.SetExpiration(0.1);
                myRobot.SetSafetyEnabled(false);
                screen->Printf(DriverStationLCD::kUser_Line2, 1, "It works $@#$@#$@#$@#$@#es!");
                screen->UpdateLCD();
               
                myRobot.TankDrive(.5, .5);
        }

        /**
        * Drive left & right motors for 2 seconds then stop
        */
        void Autonomous()
        {
                screen->Printf(DriverStationLCD::kUser_Line3, 1, "It works $@#$@#$@#$@#$@#es!");
                screen->UpdateLCD();
                myRobot.TankDrive(.5, .5);               
//                FR.SetSpeed(.5);

//                myRobot.SetSafetyEnabled(false);
//                myRobot.TankDrive(0.5, 0.5);
                Wait(2.0);                                //    for 2 seconds
//                myRobot.TankDrive(0.5, 0.5);
                Wait(2.0);
                screen->Printf(DriverStationLCD::kUser_Line4, 1, "It works $@#$@#$@#$@#$@#es!");
                screen->UpdateLCD();

        }

        /**
        * Runs the motors with arcade steering.
        */
        void OperatorControl()
        {
//                myRobot.SetSafetyEnabled(true);
//                while (IsOperatorControl())
//                {
//                        myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick)
//                        Wait(0.005);                                // wait for a motor update time
//                }
        }
       
        /**
        * Runs during test mode
        */
        void Test() {

        }
};

START_ROBOT_CLASS(RobotDemo);

Using this code the robot will not drive in autonomous.
We added DriverStationLCD objects and methods to debug and test where the code gets its errors. The code goes through autonomous perfectly, just not driving the robot. We want the robot to drive at half speed forward for 2 seconds. Thank you in advanced.

*EDIT*
Also, the jaguars do not have a solid light when the autonomous is enabled. They are continuously blinking while enabled on every setting.

Domenic Rodriguez 01-02-2014 15:41

Re: C++ Help with driving the robot forward
 
Welcome to Chief Delphi!

The Jaguar LEDs blinking yellow indicates that there is no PWM signal. Check your PWM connections and cables. Also, just a suggestion, but you might find it easier to debug drive motor issues in teleop mode than in autonomous mode.

Alan Anderson 01-02-2014 22:46

Re: C++ Help with driving the robot forward
 
Code:

// these must be initialized in the same order
// as they are declared above.

I've always treated that as deep magic that must not be tampered with. Your initializations quite reasonably put the Jaguars before the RobotDrive, but your declarations have the RobotDrive first.


All times are GMT -5. The time now is 12:49.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi