ROBOTC.net forums
http://www.robotc.net/forums/

Programming skills
http://www.robotc.net/forums/viewtopic.php?f=55&t=19543
Page 1 of 1

Author:  popolok11 [ Sun Dec 18, 2016 3:13 pm ]
Post subject:  Programming skills

I used this program for the robot Starkicker
Code:
//Movement backward to get in line with the center of the field
      motor[rearRightMotor] = -127;
     motor[frontRightMotor] = -127;
     motor[rearLeftMotor] = -127;
     motor[frontLeftMotor] = -127;
     
     wait1Msec(140);
     
     motor[rearRightMotor] = 0;
     motor[frontRightMotor] = 0;
     motor[rearLeftMotor] = 0;
     motor[frontLeftMotor] = 0;
     
     wait1Msec(100);
     
  //Clearing the encoders
     nMotorEncoder[rearRightMotor] = 0;
     nMotorEncoder[rearLeftMotor] = 0;
     
     wait1Msec(10);
 
  //Turning
while(nMotorEncoder[rearRightMotor] < 760 && nMotorEncoder[rearLeftMotor] < 760)
  {
     motor[rearRightMotor] = 127;
     motor[frontRightMotor] = 127;
     motor[rearLeftMotor] = -127;
     motor[frontLeftMotor] = -127;
  }
  wait1Msec(100);

  motor[rearRightMotor] = 0;
  motor[frontRightMotor] = 0;
  motor[rearLeftMotor] = 0;
  motor[frontLeftMotor] = 0;
 
  wait1Msec(10);
 
 
  //Clearing the encoders
  nMotorEncoder[rearRightMotor] = 0;
  nMotorEncoder[rearLeftMotor] = 0;
 
  wait1Msec(10);
 
  //Moving forward
  while(nMotorEncoder[rearRightMotor] < 3000 && nMotorEncoder[rearLeftMotor] < 3000)
  {
     motor[rearRightMotor] = 127;
     motor[frontRightMotor] = 127;
     motor[rearLeftMotor] = 127;
     motor[frontLeftMotor] = 127;
  }
 
  motor[rearRightMotor] = 0;
  motor[frontRightMotor] = 0;
  motor[rearLeftMotor] = 0;
  motor[frontLeftMotor] = 0;

  //Clearing encoders
  nMotorEncoder[rearRightMotor] = 0;
  nMotorEncoder[rearLeftMotor] = 0;
     
     wait1Msec(10);
     
     //Moving backward
  while(nMotorEncoder[rearRightMotor] < 50 && nMotorEncoder[rearLeftMotor] < 50)
  {
     motor[rearRightMotor] = -127;
     motor[frontRightMotor] = -127;
     motor[rearLeftMotor] = -127;
     motor[frontLeftMotor] = -127;
  }
 
  motor[rearRightMotor] = 0;
  motor[frontRightMotor] = 0;
  motor[rearLeftMotor] = 0;
  motor[frontLeftMotor] = 0;

  //Clearing encoders
  nMotorEncoder[rearRightMotor] = 0;
  nMotorEncoder[rearLeftMotor] = 0;
     
     wait1Msec(10);
     
     //Turning
while(nMotorEncoder[rearRightMotor] < 930 && nMotorEncoder[rearLeftMotor] < 930)
  {
     motor[rearRightMotor] = -127;
     motor[frontRightMotor] = -127;
     motor[rearLeftMotor] = 127;
     motor[frontLeftMotor] = 127;
  }
 
  motor[rearRightMotor] = 0;
  motor[frontRightMotor] = 0;
  motor[rearLeftMotor] = 0;
  motor[frontLeftMotor] = 0;
 
   //Dropping the scooper
  motor[kickerMotor] = 127;
 
  wait1Msec(100);
 
  motor[kickerMotor] = 0;
  motor[kickerArmMotor] = -127;
 
  //Clearing encoders
  nMotorEncoder[rearRightMotor] = 0;
  nMotorEncoder[rearLeftMotor] = 0;
 
  //Moving forward
  while(nMotorEncoder[rearRightMotor] < 900 && nMotorEncoder[rearLeftMotor] < 900)
  {
     motor[rearRightMotor] = 127;
     motor[frontRightMotor] = 127;
     motor[rearLeftMotor] = 127;
     motor[frontLeftMotor] = 127;
  }
 
  motor[rearRightMotor] = 0;
  motor[frontRightMotor] = 0;
  motor[rearLeftMotor] = 0;
  motor[frontLeftMotor] = 0;
 
  //Shooting
  motor[kickerArmMotor] = 127;
  motor[kickerMotor] = -127;
 
  wait1Msec(1000);
 
  motor[kickerArmMotor] = 0;
  motor[kickerMotor] = 0;


but instead of only going backward a little bit, it goes backward until it hits the wall. I have no idea why can someone please help me. I am using virtual worlds

Page 1 of 1 All times are UTC - 5 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/