View unanswered posts | View active topics It is currently Wed Jul 23, 2014 11:55 pm






Reply to topic  [ 6 posts ] 
Discrepancy with Autonomy from website 
Author Message
Rookie

Joined: Fri Feb 06, 2009 11:43 am
Posts: 11
Post Discrepancy with Autonomy from website
Since I found this problem from the website I am posting this here. Here is my situation. I am teaching RobotC using Vex to my robotics class. I have no prior experience in programming or robotics, but I am learning as we go. So far robotC lessons have been going good. We have built the squarebot 3.0 with an arm that moves up and down in conjunction with limit switches. We have encoders on the wheels and are going through the Autonomy lessons from the website.

In the PDF file from the website, on page 32 it talks about using variables to control the direction of the arm yet the graphic shows this code in lines 1-9 of the code. This is certainly confusing as we just wrote a function to move straight and placed it BEFORE task main. The code to control the arm using a button on channel six is certainly NOT on lines 1-9 as the graphic shows.

Then on page 34, it tells us to place the variable "isMovingStraight" in an outer else statement in line 90. But if you watch the VIDEOS also available on the website, they place the "isMovingStraight == False" in line 86 after we called our "move straight" function. This "else" belongs to a nested if statement we are using to make sure we can move straight when we press the lower channel 5 button. So the PDF says one thing and the video says another. VERY CONFUSING!!!

So far we followed the lessons perfectly and now when we download and compile the program, our robots do not behave as they should. I am sure we will figure out HOW the code should work. Has anybody else had problems with this?

This contradiction should be cleared up.

Ken Bowles - NBCT
Apopka High School
Physics & Engineering Dept.
kenneth.bowles@ocps.net


Fri Feb 06, 2009 6:13 pm
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Discrepancy with Autonomy from website
Hi Ken -

You're right, the numbering on page 32 should start on a line further down than "1".

In general, when copying, pasting, adding, or removing code based on the VEX lessons, I'd recommend using the "landmarks" in the code, rather than the actual line numbers (which can honestly get confusing). By landmarks, I mean the surrounding lines of code, that we always show in the PDF's and videos. For example, on page 34 we have the following code:

Code:
task main()
{
int armDirection;
bool isMovingStraight;
bIfiAutonomousMode = false;
while(vexRT[Ch5] == 0)
{
}
bMotorReflected[port2] = 1;
armDirection = 0;
isMovingStraight = false;
ClearTimer(T1);


The PDF version tells you to add the "bool isMovingStraight;" and "isMovingStraight = false;" which have surrounding code, or landmarks. The reason that I recommend this is because ROBOTC does not renumber your code until you recompile, so your program (which is what the video shows) may have any number of duplicate lines (eight lines beginning with "75", for instance).

There's a reason for that too - when debugging programs, ROBOTC lets the user know which lines have bugs. If the programmer fixes a bug on line #1 by adding another line or two, subsequent bug reports would off, making it harder to track down and fix them.

If you're still having trouble with your code, feel free to actually post it to the ROBOTC forums so others (myself included) can take a look at it.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Mon Feb 09, 2009 10:19 am
Profile
Rookie

Joined: Fri Feb 06, 2009 11:43 am
Posts: 11
Post Re: Discrepancy with Autonomy from website
Thanks for your reply. Here is the code we have constructed by following the online lessons. Please Advise.

const tSensors downLimit = (tSensors) in1; //sensorTouch //*!!!!*//
const tSensors rightEncoder = (tSensors) in2; //sensorRotation //*!!!!*//
const tSensors leftEncoder = (tSensors) in3; //sensorRotation //*!!!!*//
const tSensors upLimit = (tSensors) in4; //sensorTouch //*!!!!*//
//*!!CLICK to edit 'wizard' created sensor & motor configuration. !!*//

void moveStraight()
{if(SensorValue[leftEncoder] > SensorValue[rightEncoder])
{
motor[port3] = 50;
motor[port2] = 63;
}
if(SensorValue[leftEncoder] < SensorValue[rightEncoder])
{
motor[port3] = 63;
motor[port2] = 50;
}
if(SensorValue[leftEncoder] == SensorValue[rightEncoder])
{
motor[port3] = 63;
motor[port2] = 63;
}}

task main()
{
int armDirection;
bool isMovingStraight;
bIfiAutonomousMode = false;
while(vexRT[Ch5] == 0)
{
}
bMotorReflected[port2] = 1;

armDirection = 0;
isMovingStraight = false;
ClearTimer(T1);

while(time10[T1] < 12000)

{

if(armDirection == 1)
{
if(SensorValue(upLimit) == 0)
{
motor[port6] = 31;
}
else
{
motor[port6] = 0;
}

if(armDirection == -1)
{
if(SensorValue(downLimit) == 0)
{
motor[port6] = -31;
}
else
{
motor[port6] = 0;
}
if(armDirection == 0)
{
motor[port6] = 0;
}

if(vexRT[Ch6] == -127)

{
armDirection = 1;
}


if(vexRT[Ch6] == 127)

{
armDirection = -1;
}

if(vexRT[Ch5] == -127)
{
if(isMovingStraight == false)
{
SensorValue[leftEncoder] = 0;
SensorValue[rightEncoder] = 0;
isMovingStraight = true;
}
else
{
moveStraight();
}
}
else
{
isMovingStraight = false;
motor[port3] = vexRT[Ch3];
motor[port2] = vexRT[Ch2];
}

}
}
}
motor[port3] = 0;
motor[port2] = 0;
}


Tue Feb 10, 2009 11:19 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Discrepancy with Autonomy from website
Hi Ken -

Could you describe the type of behavior you're experiencing/not experiencing, so that when I run the code I know what to look for?

Thanks.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Wed Feb 11, 2009 4:14 pm
Profile
Rookie

Joined: Fri Feb 06, 2009 11:43 am
Posts: 11
Post Re: Discrepancy with Autonomy from website
Well, the kids say that by pressing the top channel 5 button they are able to disengage the idle loop so as to not start prematurely. So that is good. They also say that when they press the lower channel 5 button the move straight program is working. The problem is that RC control is not working. I am pretty sure the arm is working too by using the channel 6 buttons. Basically, the kids need to be able to use the operator assist function called movestraight if they need it. They need to be able to control the robot via RC as long as the lower channel 5 is not pressed. My hopes is to use the code to do the mine field challenge.


Thu Feb 12, 2009 8:20 am
Profile
Site Admin
Site Admin

Joined: Tue May 15, 2007 9:02 am
Posts: 403
Post Re: Discrepancy with Autonomy from website
Hi Ken -

I think I've found the source of your problems. In your program, you have two if statements that don't get closed until almost the very end of the program. If I copy your code and paste it directly into ROBOTC, the if statements I'm referring to begin on lines 38 and 49. There should be closing curly braces on lines 48, and after 58 to close each, I think (and two less toward the end of the program). By not closing the if statements in the correct places, all the following code gets put in one giant if statement... which would explain the weird, undesirable behavior.

Let me know if that helps.

_________________
Jesse Flot
CMU Robotics Academy
ROBOTC Support


Sun Feb 15, 2009 10:03 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron



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