View unanswered posts | View active topics It is currently Wed Jul 30, 2014 1:01 am






Reply to topic  [ 3 posts ] 
1st CheckPoint - General Palm Island 
Author Message
Rookie

Joined: Tue Jul 09, 2013 7:55 am
Posts: 1
Post 1st CheckPoint - General Palm Island
I am having real trouble running Palm Island. I can't read the tutorial, the video keeps hanging, so I'm not sure how to collect the coconuts. Also, my robot never runs consistently. I can turn after the 1st start point, but my code never runs consistently. I feel I am wasting alot of time, so I am going to continue with the rest of the course. I have attached my code that goes to the first start point, makes a left turn and goes to the end of the dock and attempts to make a right turn .
Code:
#pragma config(Sensor, S1,     touchSensor,    sensorTouch)
#pragma config(Sensor, S2,     gyroSensor,     sensorI2CHiTechnicGyro)
#pragma config(Sensor, S3,     lineFollower,   sensorLightActive)
#pragma config(Sensor, S4,     sonarSensor,    sensorSONAR)
#pragma config(Motor,  motorA,          gripperMotor,  tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorB,          rightMotor,    tmotorNXT, PIDControl, encoder)
#pragma config(Motor,  motorC,          leftMotor,     tmotorNXT, PIDControl, encoder)
//*!!Code automatically generated by 'ROBOTC' configuration wizard               !!*//

/*+++++++++++++++++++++++++++++++++++++++++++++| Notes |++++++++++++++++++++++++++++++++++++++++++++++
Mission 2 - Moving Forward and Turning
- This program will cause the robot to drive forward and turn right toward Starting Point 3.
- Your robot will wait for 2 seconds before beginning, move forward at half power for 4 rotations
   of the right motor encoder (a sensor that detects how much your wheels have spun), turn right for
   1/4 of a rotation of the right motor encoder and then stop.
- ROBOTC must be in Natural Language mode for this program to run. You can set this in the top menu
   by going to Robot > Platform Type > LEGO Mindstorms > Natural Language (NXT).
*   Please note that the values in this program were written for Mammalbot using a high-end computer.
   You may need to adjust the values in this program for your computer.

Robot Model: Mammalbot

[I/O Port]          [Name]              [Type]                   [Description]
Motor Port B        rightMotor          Motor w/ Encoder           Right side motor
Motor Port C        leftMotor           Motor w/ Encoder           Left side motor
----------------------------------------------------------------------------------------------------*/

task main()
{
   //Wait for 2 seconds before moving forward
   wait(2.0);

   //Move forward at half speed for 4 rotations of the right motor encoder, and stop
   forward(50);
  untilEncoderCounts(875);

   //Wait for 1 second before turning
   wait(1.0);

   //Point turn to the left at half speed for 90 counts of the right motor encoder, and stop
   pointTurn(left, 120);
   untilEncoderCounts(200, rightMotor);
   stop();

   forward (50);
   untilEncoderCounts(1400, rightMotor);
   stop();

   //Wait for 1 second before turning
   wait(1.0);
      //Point turn to the right at half speed for 50 counts of the right motor encoder, and stop
   pointTurn(right, 50);
   untilEncoderCounts(170, rightMotor);
   stop();

   forward(50);
  untilEncoderCounts(1300, rightMotor);
   stop();


}



Thanks Rose


Tue Jul 09, 2013 8:23 am
Profile
Moderator
Moderator

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 179
Post Re: 1st CheckPoint - General Palm Island
Hi Rose,

Let's take a look at your code:

Code:
task main()
{
   //Wait for 2 seconds before moving forward
   wait(2.0);

   //Move forward at half speed for 4 rotations of the right motor encoder, and stop
   forward(50);
  untilEncoderCounts(875);

   //Wait for 1 second before turning
   wait(1.0);


In this portion, you do not have a command for the robot to stop. Try including a stop command before the wait(1.0). This will make your robot stop for one second. That should make the beginning portion a little more reliable.

Code:
 //Point turn to the left at half speed for 90 counts of the right motor encoder, and stop
   pointTurn(left, 120);
   untilEncoderCounts(200, rightMotor);
   stop();


In this section, the speed of the point turn is much higher than half speed, you have it at 120. The max speed is 100. Trying slowing the speed of the turn down in order to make it more reliable.

Code:
 //Point turn to the right at half speed for 50 counts of the right motor encoder, and stop
   pointTurn(right, 50);
   untilEncoderCounts(170, rightMotor);
   stop();


In this section of code, include a wait(1.0) so the robot, once again, stops for a second.

As you mention, if the robot goes from one movement immediately into the next (move forward, then turn), the movement is not going to be reliable. Use the analogy of a car. If a car was moving forward and then immediately turned (without slowing down), the turn would not be very reliable. The same thing applies to the robot. That is what is causing the unreliability. The errors accumulate, and you get the unreliable code.

Additionally, to avoid the accumulating error, Palm Island has the different starting points. So, after your robot moves forward and turns left, you should be able to begin from that starting point from then on (just remember to log in using your CS2N account so your progress is saved). From there, your pseudocode to the next starting point would look like this:

move forward
stop for a second
turn right
stop for a second
move forward
stop

From that point you should once again be able to open up a new starting point so your robot does not have to repeat these behaviors again.

For the coconuts, all you have to do is collect them. Not sure what is going on with your tutorials. Please provide a little more detail so we can try to help with that. Thanks,


Tue Jul 09, 2013 3:57 pm
Profile
Moderator
Moderator

Joined: Mon Oct 04, 2010 2:18 pm
Posts: 179
Post Re: 1st CheckPoint - General Palm Island
Also, if you have questions about the different starting points, use the Palm Island Map that is available to you. It is a great resource.


Tue Jul 09, 2013 3:57 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

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



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