View unanswered posts | View active topics It is currently Wed Mar 29, 2017 3:11 pm






Reply to topic  [ 1 post ] 
Programming skills 
Author Message
Rookie

Joined: Sun Feb 14, 2016 11:56 am
Posts: 5
Post 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


Sun Dec 18, 2016 3:13 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  



Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.