Our robot is having some major issues at the moment. Currently our robot will work with the joystick for a couple seconds before the robot stops moving. We’ve tried lowering the power of all the motors and we’re currently wondering if we need to either change the wheels from mecanum wheels to regular or omni-wheels or change the gear ratio(which would be a massive pain). Here’s a copy of our user control code:
#pragma config(Motor, port1, box, tmotorVex393_HBridge, openLoop)
#pragma config(Motor, port4, liftRight, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port5, liftLeft, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port6, backRight, tmotorVex393_MC29, openLoop, driveRight)
#pragma config(Motor, port7, frontRight, tmotorVex393_MC29, openLoop, reversed, driveRight)
#pragma config(Motor, port8, backLeft, tmotorVex393_MC29, openLoop, reversed, driveLeft)
#pragma config(Motor, port9, frontLeft, tmotorVex393_MC29, openLoop, driveLeft)
#pragma config(Motor, port10, claw, tmotorVex393_HBridge, openLoop)
//!!Code automatically generated by ‘ROBOTC’ configuration wizard !!//
#pragma platform(VEX2)
#pragma competitionControl(Competition)
#include “Vex_Competition_Includes.c”
int BOX_UP = 0;
int BOX_DOWN = 0;
// Setup for competition
void pre_auton()
{
// This code is how many inches the robot moves forward between one tick of the left and right wheel encoders.
// Calculations: Diameter of 4" so C=pi*d circumference (C) is 4pi; accounting for the gear ratio of 60:12 = 5:1 : ticks per revolution (TpR) is 125.44; C/TpR = distance per tick (IpT); IpT=0.100178337.
// Set encoder values to zero
nMotorEncoder [frontRight] = 0;
nMotorEncoder [backRight] = 0;
// Stops extra tasks between auton and driver control
bStopTasksBetweenModes = true;
}
// Converts ticks for the driving encoders to inches that the robot moved
float INCHES_PER_TICK = 0.100178337;
float inchesCalc (float inches)
{
return inches / INCHES_PER_TICK;
}
/*void forward()
{
motor[frontLeft] = 63;
motor[backLeft] = 63;
motor[frontRight] = 63;
motor[backRight] = 63;
}
void left()
{
motor[frontRight] = 63;
motor[frontLeft] = -63;
motor[backRight] = 63;
motor[backLeft] = -63;
}
void right()
{
motor[frontRight] = -63;
motor[frontLeft] = 63;
motor[backRight] = -63;
motor[backLeft] = 63;
}
void counterTurn()
{
motor[leftMotor] = -63;
motor[leftMotor] = -63;
motor[rightMotor] = 63;
motor[rightMotor] = 63;
}
void clockTurn()
{
motor[leftMotor] = 63;
motor[leftMotor] = 63;
motor[rightMotor] = -63;
motor[rightMotor] = -63;
}*/
/*
AUTONOMOUS CODE PLAN
Currently, no plan.
*/
task autonomous()
{
/*int quarterTurn = -6000;
int clockeighthTurn = -3000;
{
while(nMotorEncoder[leftMotor] < inchesCalc (8.5)) //Robot goes forward 8.5 inches
{
forward();
}
while(nMotorEncoder[leftMotor] < inchesCalc (17)) //Robot goes to the right 17.0 inches
{
right();
}
while(SensorValue[leftMotor] < eighthTurn)
{
clockTurn();
}
// while(nMotorEncoder[leftMotor] , inchesCalc (24) //Robot
}*/
}
/*
DRIVER CONTROL PLAN
TODO
- Add forward/back/turn control
- Make joystick values incorporate whichever type currently isn’t active
- Add Mechanum capabilities
- Adjust to make robot easy to control
*/
task boxUp ()
{
while (nMotorEncoder[box] < BOX_UP)
{
motor[box] = 63;
}
motor[box] = 0;
}
task boxDown ()
{
while (nMotorEncoder[box] > BOX_DOWN)
{
motor[box] = -63;
}
motor[box] = 0;
}
task usercontrol()
{
while (true)
{
int fCh = (((abs (vexRT [Ch2]) > 20) ? abs (vexRT [Ch2]) : 0) + ((abs (vexRT [Ch3]) > 20) ? abs (vexRT [Ch3]) : 0)) / 2;
int sCh = abs ((((abs (vexRT [Ch1]) > 20) ? vexRT [Ch1] : 0) + ((abs (vexRT [Ch4]) > 20) ? vexRT [Ch4] : 0)) / 2);
writeDebugStream (“%d %d %d\n”, sCh, vexRT [Ch4], vexRT [Ch1]);
if (fCh > sCh)
{
float lF = vexRT [Ch3] / 63;
float rF = vexRT [Ch2] / 63;
float lS = vexRT [Ch4] / 63;
float rS = vexRT [Ch1] / 63;
float lCh = lF * lF + lS * lS;
float rCh = rF * rF + rS * rS;
int l = lCh * 127 * ((vexRT [Ch3] < 0) ? -1 : 1);
int r = rCh * 127 * ((vexRT [Ch2] < 0) ? -1 : 1);
//writeDebugStream (“l: %d\n”, l);
if (abs (r) > 20)
{
motor [frontRight] = r;
motor [backRight] = r;
}
else
{
motor [frontRight] = 0;
motor [backRight] = 0;
}
if (abs (l) > 20)
{
motor [frontLeft] = l;
motor [backLeft] = l;
}
else
{
motor [frontLeft] = 0;
motor [backLeft] = 0;
}
}
else if (sCh > 30)
{
float lF = vexRT [Ch3] / 63;
float rF = vexRT [Ch2] / 63;
float lS = vexRT [Ch4] / 63;
float rS = vexRT [Ch1] / 63;
float lCh = lF * lF + lS * lS;
float rCh = rF * rF + rS * rS;
int l = lCh * 127 * ((vexRT [Ch4] < 0) ? -1 : 1);
int r = rCh * 127 * ((vexRT [Ch1] < 0) ? -1 : 1);
int s = (l + r) / 2;
if (abs (s) > 30)
{
motor [frontLeft] = s;
motor [frontRight] = -s;
motor [backLeft] = -s;
motor [backRight] = s;
}
else
{
motor [frontLeft] = 0;
motor [frontRight] = 0;
motor [backLeft] = 0;
motor [backRight] = 0;
}
}
else
{
motor [frontLeft] = 0;
motor [frontRight] = 0;
motor [backLeft] = 0;
motor [backRight] = 0;
}
if (vexRT[Btn6U])
{
motor[liftLeft] = 80;
motor[liftRight] = 80;
}
else if (vexRT[Btn6D])
{
motor[liftLeft] = -80;
motor[liftRight] = -80;
}
else
{
motor[liftLeft] = 0;
motor[liftRight] = 0;
}
if (vexRT[Btn5U])
{
motor[claw] = 70;
}
else if (vexRT[Btn5D])
{
motor[claw] = -70;
}
else
{
motor[claw] = 0;
}
if (vexRT[Btn8U])
{
startTask (boxUp);
}
if (vexRT[Btn8R])
{
startTask (boxDown);
}
}
}