View unanswered posts | View active topics It is currently Tue Jun 19, 2018 11:42 pm






Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3
Autonomous Turning using HiTechnic Gyro 
Author Message
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Autonomous Turning using HiTechnic Gyro
robofan785 wrote:
I am trying to move a linear slide up to a certain level when a button is pressed. The linear slide should move to another level when another button is pressed. However the robot should know it's already at a certain level and move up or down to the next level of height accordingly. How do I do this? Some suggested using stacks...

In order to do that, you must have some sort of feedback on your linear slide, perhaps an encoder, that tells you the position of the slide. If so, then it's very easy. When a button is pressed, you read the encoder to determine the current slide position and then calculate the difference in height and the direction the slide has to go. That's it. You can even use PID control to get there smoothly and accurately.


Mon Feb 02, 2015 6:03 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Autonomous Turning using HiTechnic Gyro
akash329dsouza wrote:
Also, MHTS if I understood this correctly , you should be able to get the same amount of accuracy with just 1 IR Seeker but the only difference would be that we wouldn't get full 360 degree vision. So for example, if the robot went on the path shown on the image, and then turned right until it saw the beacon. Would we get the same amount of accuracy as if we had 2 seekers? We are trying to decide if it is worth it to buy another IR Seeker. Another way we thought to do this is to drive up and turn right until the ultrasonic saw nothing, then turn left until the untrasonic saw nothing and then go half the distance inbetween them. Do you think either of these ideas would be as accurate as using 2 IR seekers?

Well, I still think 2 IR seekers will be more accurate than one because when one IR seeker reports the beacon at an odd number zone (e.g. 3), it means it has a very wide angle whereas if you have two that are oriented in different directions, it gives you a second input that together you get a more accurate picture of where the IR beacon is. However, it is possible to use one IR seeker utilizing the narrower zone (even number zones) to zoom in with acceptable accuracy. Our team always use two seekers and they are very accurate so I can't tell you quantitatively how much better it performs in comparison to just one. I would recommend you just try it out and see if one is acceptable. If it can do the job, then you are fine. At competition, majority of the teams are using just one and they seem to perform fine. But of course, with only one, the strategy on how to approach the beacon as well as the placement of the seeker may be a factor on the accuracy. For example, if your robot can move sideways (i.e. mecanum or diamond formation Omni-wheels), you can approach the beacon on the left side then slide to the right. If you are using zone 2 or 8 to detect the beacon, I think you will be quite accurate. A lot of teams do that. Now if your robot cannot do sideways then it means you have to approach the beacon directly in front and adjust the angle of approach as you go. That may be more difficult with one seeker. As you have seen in our video, our robot cannot do sideways, so we first use the seeker to determine whether the center goal is at position 1, 2 or 3. Then we select the appropriate path to approach the beacon to its left, once we pass the beacon, we use the IR seekers to direct the robot to turn right to align with it, then we use the ultrasonic sensor to guide us the distance to go forward while using the two seekers to maintain the correct alignment.


Mon Feb 02, 2015 6:23 pm
Profile
Novice

Joined: Tue Dec 16, 2014 10:25 am
Posts: 81
Post Re: Autonomous Turning using HiTechnic Gyro
So we tried your code with 2 IR Seekers and we would always get 7 and 3 and the robot would be off center. Is there any way to fix this?

_________________
Thanks!


Sat Feb 07, 2015 6:12 pm
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Autonomous Turning using HiTechnic Gyro
What does your code look like?


Sun Feb 08, 2015 2:53 am
Profile
Novice

Joined: Tue Dec 16, 2014 10:25 am
Posts: 81
Post Re: Autonomous Turning using HiTechnic Gyro
We used your sample code in the previous page.
Edit:
Oops forgot we changed it a bit for a pid Drive but I don't think that would matter too much because it did the same thing as your sample code. Here's the code:
Code:
task main()
{
   int Speed = -30;
   int dist = USreadDist(LEGOUS123);
    while (dist < 83)
    {
       dist = USreadDist(LEGOUS123);
        float irDir = IRGetACDir(leftIR,1) + IRGetACDir(rightIR,2);
        float error = irDir - 10.0;
        nxtDisplayTextLine(3, "Error=%d,Dir=%5.1f", error, 1);
        motor[motorF] =Speed + (Kp*error);
        motor[motorG] = Speed + (Kp*error;
        motor[motorD] = Speed - (Kp*error;
        motor[motorE] = Speed - (Kp*error;
        wait1Msec(20);
    }
}

(This was just temporary testing code)
We also changed your driver code a bit so we could see idx values from each sensor(They were overlapping)
Code:
float IRGetACDir(tMUXSensor link, int line)
{
    static float prevDir = 0.0; //Create variables
    float currDir;
    int acS[5];
    int idx;
    idx = HTIRS2readACDir(link);  //Read current zone and store in idx
    currDir = (float)idx; //Store current zone as a float instead of an integer
    if (idx == 0)// if HTIRS2readACDir returns 0, it means it lost the IR beacon. In that case we use the ACDir determined previously.
    {
        currDir = prevDir;
    }
    else if (HTIRS2readAllACStrength(link, acS[0], acS[1], acS[2], acS[3], acS[4])) //Read the strength values of all 5 sensors.
    {
        idx = (idx - 1)/2; //translate the zone value into the sensor number 0 to 4. For example, zone 4 yielded idx 1.
        if ((idx < 4) && (acS[idx] != 0) && (acS[idx + 1] != 0)) //if sensor number and sensor number + 1 are still within 0 through 4 and if sensor number and sensor number + 1 both have non-zero strength
        {
            // calculate the .x proportion value from the relative strength of the two adjacent sensors. The result could be a positive or a negative number smaller than 1.0. Then add this .x number to the original zone number from HTIRS2readACDir.
            currDir += (float)(acS[idx + 1] - acS[idx])/
                          max(acS[idx], acS[idx + 1]);
        }
        nxtDisplayTextLine(line, "Idx=%d,Dir=%5.1f", idx, currDir);
    }
    prevDir = currDir; // remember the current zone value in case the next time we lost the IR beacon.

    return currDir;
}

_________________
Thanks!


Sun Feb 08, 2015 9:34 am
Profile
Novice

Joined: Tue Dec 16, 2014 10:25 am
Posts: 81
Post Re: Autonomous Turning using HiTechnic Gyro
It seems like we got everything right. For now we tilted the seekers inward so that we got 8 & 2 but in your videos you didn't have to do this.Does it look like a programming issue?

_________________
Thanks!


Tue Feb 10, 2015 1:07 am
Profile
Guru
User avatar

Joined: Sun Nov 15, 2009 5:46 am
Posts: 1523
Post Re: Autonomous Turning using HiTechnic Gyro
Zone 8 and 2 are the narrow zones, so naturally it will give you more accuracy. I don't quite understand what your scenario is? Are you saying that when you are up against the IR beacon, you are still reading 7 and 3 and it wasn't quite aligned? If so, how did you approach the beacon? Are you going forward towards it so the beacons reads 8 and 2, then 7 and 3, then 6 and 4? Or are you approaching sideways? Understanding how the Seeker works will allow to come up with strategies to make it more accurate. It sounds like you are tilting the sensor inwards even more to take advantage of zone 8 and 2. That's good.
In our case, we don't need to do that because we are going towards the beacon head on using the seekers to correct the align while moving forward. So, initially, we have 8 and 2 which is already pointing to the beacon ahead when one seeker transitions to another number say from 8 to 7 and if the other beacon is still at 2, it will turn and correct it until it's on 3 so because of the progressive correction, we are keeping the course straight. There are a few cases where it may miss the alignment (e.g. at center goal position 1) where we need to do a sharp turn. In that case, we could actually set the target to something other than 10, say 10.5 or even 11 to force over correction if the alignment is slightly off at an angle. So be creative on coding this.


Tue Feb 10, 2015 2:36 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 37 posts ]  Go to page Previous  1, 2, 3

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.