Ask Experts Questions for FREE Help !
Ask
    AlaaMayyaleh's Avatar
    AlaaMayyaleh Posts: 1, Reputation: 1
    New Member
     
    #1

    Feb 25, 2016, 03:29 AM
    Finch Robot follow object
    [FONT=Open Sans, Arial, Helvetica, sans-serif][SIZE=4][COLOR=#000000]Hello ,[/COLOR][/SIZE][/FONT]
    [FONT=Open Sans, Arial, Helvetica, sans-serif][SIZE=4][COLOR=#000000][/COLOR][/SIZE][/FONT]
    I am writing a program where I have to make my finch robot follow an object. I have written it so that the finch will begin by sensing objects around it once it has been tapped on the top. As soon as I tap the top and cover the sensors, a red light is supposed to turn on and it will follow the object in the direction of the covered sensor. While it is moving, it should be making a buzzing sound and have the light change from red to green. When I stop moving the object, the finch is supposed to turn it's nose back to red and wait until it is either tapped twice to end the program or until the object is moved for it to continue following. However, when I tap it, nothing happens.

    Here is my code


    import edu.cmu.ri.createlab.terk.robot.finch.Finch;

    public class FollowingAnObject {

    static Finch myF = new Finch();

    public static void main(String[] args) {
    myF = new Finch();
    }

    public FollowingAnObject() {
    while (true) {
    //This begins the movement of the finch
    if (myF.isTapped() == true && myF.isObstacleLeftSide() == true && myF.isObstacleRightSide() == true && myF.isObstacle() == true) {
    //LED colours are red, green and blue
    myF.setLED(R, 0, 0);
    myF.setWheelVelocities(velocityLeft, velocityRight);

    //Triggers the RunAgain function to true so that the program does not stop in one run so that the Finch will continue to move
    boolean RunAgain = true;

    while (RunAgain) {
    //Calling the Move method for the Finch movements
    Move();
    //Inside the while, RunAgain loop , there is a conditional statement that makes the program terminate if the Finch has been tapped twice
    if (myF.isTapped() == true && myF.isTapped() == true) {
    break;
    }
    }
    }
    }
    }

    // Method for all of the Finch movements
    public static void Move() {
    if (myF.isObstacleRightSide() == false && myF.isObstacleLeftSide() == false && myF.isObstacle() == true) {
    MoveStraight();
    } else if (myF.isObstacleRightSide() == false && myF.isObstacleLeftSide() == true) {
    MoveLeft();
    } else if (myF.isObstacleRightSide() == true && myF.isObstacleLeftSide() == false) {
    MoveRight();
    } else if (myF.isObstacleRightSide() == true && myF.isObstacleLeftSide() == true) {
    StopMoving();
    }
    }

    //All of the variables have been declared
    static int Buzz = 300;
    static int BuzzDuration = 12;

    static int R = 250;
    static int G = 250;

    static int velocityLeft = 150;
    static int velocityRight = 150;

    static int turnLeft = -50;
    static int turnRight = -50;

    //If the finch is moving straight, the light will be green and both of the wheels will move at 150
    public static void MoveStraight() {
    myF.setLED(0, G, 0);
    myF.setWheelVelocities(velocityLeft, velocityRight);
    myF.buzz(Buzz, BuzzDuration);
    }

    public static void MoveLeft() {
    //If the finch is moving left, the light will be green, the left wheel will move at -50 and the right wheel will move at 150
    myF.setLED(0, G, 0);
    myF.setWheelVelocities(turnLeft, velocityRight);
    myF.buzz(Buzz, BuzzDuration);

    }

    public static void MoveRight() //If the finch is moving right, the light will be green the left wheel will move at 150 and the right wheel will move at -50
    {
    myF.setLED(0, G, 0);
    myF.setWheelVelocities(velocityLeft, turnRight);
    myF.buzz(Buzz, BuzzDuration);

    }

    public static void StopMoving() //if the Finch is not moving, the colour of the light will be red and the buzzing will stop
    {
    myF.setLED(R, 0, 0);
    myF.stopWheels();
    myF.buzz(Buzz, BuzzDuration);
    }
    }
    Attached Images
     

Check out some similar questions!

A change in the gravitation force acting on an object will affect the object's [ 1 Answers ]

A.mass B.coefficient of static friction C.weight D.inertia

A man built a robot to have as a son. This robot eventually started having 'feelings [ 3 Answers ]

A man builds a robot to be his teen or pre-teen son. The robot needs to have his 'battery' changed at night. I think eventually the robot starts to feel emotions. I think it would have been in the 70s or 80s.

Can you identify this finch breed? [ 2 Answers ]

My neighbor's cat caught a bird. I know that it was a finch and it had a leg band on so it must have been someone's pet at one time. :( I would like help in identifying it's breed. It was mostly olive-green; bright yellow stripe on it's head with 2 black stripes, one on each side of the yellow...

Finch death [ 1 Answers ]

I have been keeping finches for about 2 yrs and had a large healthy stock .I bought one from a shop and I lost half my stock in a week,I put it down to the new bird being sick and infecting but it has happened on three more occasions now I have none left . Any ideas?


View more questions Search
 

Question Tools Search this Question
Search this Question:

Advanced Search

Add your answer here.