Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   C/C++ (http://www.chiefdelphi.com/forums/forumdisplay.php?f=183)
-   -   CIM motor fun (http://www.chiefdelphi.com/forums/showthread.php?t=91760)

tomy 13-02-2011 21:58

CIM motor fun
 
yesterday we test our driving with a xbox 360 controller. it worked fine except for one thing. One of the motors is moving, what we think, twice the speed of the others. We have changed the pwms and double check the connection to the jaguars. Could it be the code????

tomy 13-02-2011 22:07

Re: CIM motor fun
 
For reference here is our Telop code

Code:

        void OperatorControl(void)
        {
                myRobot.SetSafetyEnabled(true);
                en1.Reset();
                gyro.Reset();
                AxisCamera &robocam = AxisCamera::GetInstance();
                robocam.WriteResolution((AxisCamera::Resolution_t)3);
                robocam.WriteBrightness(0);
                Wait(3.0);
       
               
                while (IsOperatorControl())
                {
                // read digital inputs       
                unsigned short leftValue = left->Get() ? 4 : 0;        // read the line tracking sensors
                unsigned short middleValue = middle->Get() ? 2 : 0;
                unsigned short rightValue = right->Get() ? 1 : 0;
               
                //Look for line sensor inputs only when  right bumber is pressed
                if (xbox.GetRightBumper()){
                        switch(leftValue + middleValue + rightValue){
                        case(0x0): // normal operation
                        case(0x5):
                        case(0x7):{
                                        //printf("no line found \n");
                                        //void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
                                        if (!xbox.GetLeftBumper()){
                                                myRobot.MecanumDrive_Cartesian(xbox.GetLeftX(), xbox.GetRightY(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
                                        }
                                        else{
                                                myRobot.MecanumDrive_Cartesian(xbox.GetLeftX()/2, xbox.GetRightY()/2, -xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed
                                        }
                                        break;
                                        }
                        case(0x1):        // straif right
                        case(0x3):{
                                        // printf("right leftstickX = %f, abs = %i\n",leftstick.GetX(), abs((int)leftstick.GetX()));
                                        float leftvalue = (fabs(xbox.GetLeftX())/-2);
                                        //printf("right leftstickX = %f\n", leftvalue);
                                        myRobot.MecanumDrive_Cartesian(leftvalue, 0, -xbox.GetLeftX(), 0);
                                        break;
                                        }
                        case(0x2):{ // keep going
                                        //printf("middle \n");
                                        myRobot.MecanumDrive_Cartesian(0, 0, -xbox.GetLeftX(), 0);
                                        break;
                                        }
                        case(0x4): // straif left
                        case(0x6):{
                                        //printf("left \n");
                                        float rightvalue = (fabs(xbox.GetLeftX())/2);
                                        //printf("left leftstickX = %f\n", rightvalue);
                                        myRobot.MecanumDrive_Cartesian(rightvalue, 0, -xbox.GetLeftX(), 0);
                                        break;
                                        }
                        default:
                                        break;
                        }
                }
                else {
                        //This is how the robot will drive if the right bumper is not pressed
                        //void MecanumDrive_Cartesian(float x, float rotation, float y, float gyroAngle = 0.0);
                        if (!xbox.GetLeftBumper()){
                                myRobot.MecanumDrive_Cartesian(-xbox.GetLeftX(), -xbox.GetRightY(), -xbox.GetLeftY(), 0); //Mecanum drive at full speed
                        }
                        else{
                                myRobot.MecanumDrive_Cartesian(-xbox.GetLeftX()/2, -xbox.GetRightY()/2, -xbox.GetLeftY()/2, 0);//Mecanumdrive at half speed
                        }                       
                }


tomy 14-02-2011 15:28

Re: CIM motor fun
 
Anyone know what the problem is cause we cant figure it out and its getting frustrating...

mikets 14-02-2011 21:20

Re: CIM motor fun
 
You did not describe too much detail on what the problem was. For example, under what condition when the problem occurred (i.e. which button did you push or what were the joystick positions, basically which code path it took)? Which motor is moving twice the speed as the others? What happens if you move the joysticks? I don't quite understand your code. While it is teleop code, you are reading the light sensors to follow the line but yet you are also reading the joysticks too? Are you doing some sort of assisted drive? If you want somebody to comment, you need to give more details on what you are trying to do and what are the symptoms.

CodeMonkeyMatt 14-02-2011 21:22

Re: CIM motor fun
 
Not an expert by any means, but hopefully someone will come along that can help more. In the meantime, have you tried calibrating the jaguars? They should be pre-calibrated, but it's worth a shot if you have nothing else to try.

tomy 14-02-2011 23:28

Re: CIM motor fun
 
We got it

CodeMonkeyMatt 17-02-2011 02:09

Re: CIM motor fun
 
Just curious. What was the problem and solution?

tomy 17-02-2011 07:00

Re: CIM motor fun
 
We had to recalivrate them


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

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