View unanswered posts | View active topics It is currently Mon Oct 20, 2014 8:35 pm






Reply to topic  [ 8 posts ] 
Ftc Autonomous 
Author Message
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
Post Ftc Autonomous
Currently when I use the Ir seeker to try to find the Ir beacon my robot can find it but it does not know when to stop. How could I tell it when to stop? Also the robot is at a angle when it reaches the beacon. Is there a way that I could have it align better with it? Thanks for your help.


Wed Feb 06, 2013 9:32 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 591
Post Re: Ftc Autonomous
Would you be able to post your code using the [code] tags? This will help us see where you're at and allow us to debug the program with you.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Wed Feb 06, 2013 11:06 pm
Profile
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
Post Re: Ftc Autonomous
Code:
#pragma config(Hubs,  S1, HTMotor,  HTMotor,  none,     none)
#pragma config(Sensor, S2,     Ir,              sensorI2CCustom)
#pragma config(Sensor, S3,     Color,               sensorI2CCustom)
#pragma config(Motor,  mtr_S1_C1_1,     leftdrive,     tmotorTetrix, openLoop, reversed)
#pragma config(Motor,  mtr_S1_C1_2,     rightdrive,    tmotorTetrix, openLoop)
#pragma config(Motor,  mtr_S1_C2_1,     arm,           tmotorTetrix, openLoop)

#include "JoystickDriver.c"
#include "drivers/hitechnic-irseeker-v2.h"
#include "drivers/hitechnic-colour-v2.h"

task main(){

  waitForStart();

  motor[leftdrive] = 100;
  motor[rightdrive] = 100;

  wait1Msec(600);

  motor[leftdrive] = 100;
  motor[rightdrive] = -100;

  wait1Msec(430);

  motor[leftdrive] = 100;
  motor[rightdrive] = 100;

  wait1Msec(700);

  motor[leftdrive] = 0;
  motor[rightdrive] = 0;

  HTIRS2setDSPMode(Ir, DSP_1200);

  int dir = 0;

  while(dir == 0) {

    int dirAC = HTIRS2readACDir(Ir);

    if (dirAC == 5)
    {
       dir = 2;
    }

    else if (dirAC < 5 && dirAC > 0)
    {
       dir = 1;
    }

    else if (dirAC > 5)
    {
       dir = 3;
    }
  }

  if (dir == 1)
  {
     motor[leftdrive] = 100;
     motor[rightdrive] = -100;

    wait1Msec(200);

     motor[leftdrive] = 100;
     motor[rightdrive] = 100;

    wait1Msec(500);

     motor[leftdrive] = -100;
     motor[rightdrive] = 100;

    wait1Msec(200);

     motor[leftdrive] = 100;
     motor[rightdrive] = 100;

    wait1Msec(200);
  }

  else if (dir == 2)
  {
     motor[leftdrive] = 100;
     motor[rightdrive] = 100;

    wait1Msec(500);

     motor[leftdrive] = 0;
     motor[rightdrive] = 0;
  }

  else if (dir == 3)
  {
     motor[leftdrive] = -100;
     motor[rightdrive] = 100;

    wait1Msec(200);

     motor[leftdrive] = 100;
     motor[rightdrive] = 100;

    wait1Msec(500);

     motor[leftdrive] = 100;
     motor[rightdrive] = -100;

    wait1Msec(200);

     motor[leftdrive] = 100;
     motor[rightdrive] = 100;

    wait1Msec(200);
  }

  int _color = 0;
  int sweep = 0;

  while (true)
  {
     _color = HTCS2readColor(Color);

     if (_color == 17)
     {
        motor[leftdrive] = 100;
        motor[rightdrive] = 100;
    }

     else if (_color != 17 && sweep == 0)
     {
        motor[leftdrive] = 50;
        motor[rightdrive] = -50;

        sweep = 1;

        wait1Msec(300);
    }

     else if (_color != 17 && sweep == 1)
     {
        motor[leftdrive] = -50;
        motor[rightdrive] = 50;

        sweep = 0;

        wait1Msec(300);
    }

    else
    {
        motor[leftdrive] = 0;
        motor[rightdrive] = 0;
    }

  }

}


Thu Feb 07, 2013 3:51 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 591
Post Re: Ftc Autonomous
Without knowing the exact layout of the robot and how each sensor is being used on the robot, I'm going to assume the following may be the issue;

Code:
 while (true)
  {
     _color = HTCS2readColor(Color);

     if (_color == 17)
     {
        motor[leftdrive] = 100;
        motor[rightdrive] = 100;
    }

    //rest of code

  }


If the _color sensor is continually reading a value of 17, it will keep both motors moving at 100 power perpetually; again, this does depend on how the robot is set up and what each sensors' function on the robot is, but this would be my initial guess of where the issue may lie.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Feb 08, 2013 10:34 am
Profile
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
Post Re: Ftc Autonomous
Sorry for not explaining my problem better. I know that will make it move forever, i just didn't know how to make it stop when it was at the column. The robot first aligns with the center board, facing the 3 column. Then it uses the ir sensor to check if its on column 1, 2, or 3. Then it drives to the column and uses the white line to drive towards it. The problem is it always drives towards the center one. The other problem is it does not know when to stop when its at the column. Thanks for your help.


Fri Feb 08, 2013 2:22 pm
Profile
Site Admin
Site Admin

Joined: Thu May 24, 2012 12:15 pm
Posts: 591
Post Re: Ftc Autonomous
Do you have any other sensors that could keep track of distance (such as encoders on the TETRIX motors or a sonar sensor to detect how far away from an object the robot is)? Without these, the next option would be more time based movements, which isn't the most reliable method of moving a robot.

Either way, the real culprit in this case is the while(true) segment; these loops are called 'infinite loops' and will continue to run forever. There are ways around this, but a much more practical way to control how long the loop runs would be:

Code:
while(SensorValue[sensor] < someValue)
{
//Do things
}

or

ClearTimer[T1];

while(Time1[T1] < 10000)
{
//This code will run for 10 seconds
}


The first loop will execute the code inside of the while loop until the 'sensor' becomes greater than an certain value. The second loop will run for 10 seconds, using the internal NXT timers to keep track of time. Again, your best option (if applicable) would be the sensor method.

_________________
Check out our Blog! And our Facebook page!
Need help? Take a look at our Wiki and our Forums.

I just met you,
And this is crazy,
But here's my code now,
So fix it, maybe?
~ Carly Rae Jepsen parody


Fri Feb 08, 2013 6:23 pm
Profile
Rookie

Joined: Wed Feb 06, 2013 6:10 pm
Posts: 12
Post Re: Ftc Autonomous
I know that I just did that for testing. The bigger problem is that for some reason it only wants to go to the center column.


Fri Feb 08, 2013 8:40 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1347
Post Re: Ftc Autonomous
To determine when to stop, you need sensors that tell you how close you are from the column. There are many ways to achieve this. One way is to use an ultrasonic sensor to determine the distance to the bottom cross bar. That's what our team did. Another way is to use IR seekers to do triangulation. There were threads discussing using the raw signal strength of the IR seekers to determine the distance, but in my opinion, this is not very reliable because the raw strength will be different depending on the battery level of the beacon and individual IR seeker. So, I wouldn't recommend it.


Mon Feb 11, 2013 4:25 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 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:  



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