Finch Robot

What the Finch Robot Is..

The Finch Robot is a programmable bird-shaped bot that can be coded with most of the languages such as Java, Python, and Greenfoot. It has accelerometers, LED lights, two infrared eyes for detecting walls, a temperature senor, light sensors and two motor powered wheels in the front. It is also able to withstand falling off of tables (which I learned a few times, on accident of course).

The Finch Robot

What My Robot Can Do:

I attempted to program my robot to find its way through a maze. It will detect a wall and turn itself away if a wall is found. When encountering a wall, the robot plays a beeping sound and flashes the LED. It also utilizes the light sensors so when the robot is moved to a dark environment it panics and reverses itself for a certain programmed amount of time. When there are no obstacles and everything is just peachy, the LED shows green, and when danger is near or the robot is in an uncomfortable spot, the LED flashes many colors to alert of its scaredness.

The Problems I Faced..

I decided to use Greenfoot to program my robot. The toughest challenge was not a just single part, it was finding how to code something that I had no prior experience with. We had done coding with Java in class but I had never used code to program a robot or anything along those lines. I had to use the Finch website to find the Java API in order to know what I could make the robot do. I found that the robot has pre-coded functions that I could call without having to set them up myself. This made coding simpler, but I still was not too sure how to implement the functions. Another problem I ran into was that the wall-detecting sensors did not work too well together so I discovered that if one “eye” is covered, the whole robot responds better. The version of the robot that I was using was an early version, so the sensors and its reliability were not too good to work with.

Examples of Difficult Code:

The time implementation for the robot reversing when in the dark I found was extra difficult. I had never used time code before in Java and I had to do a little research and experimentation to see how it worked. Here is an example of my time code:

if ((((finch.getRightLightLevel()) < 30) && (finch.getLeftLightLevel()) < 30))
{
long start = System.currentTimeMillis( );
while (start + 1000 > System.currentTimeMillis())
{
finch.setWheelSpeeds(-100,-100);
}
}

I had a hard time finding the System.currentTimeMillis() and struggled to implement it in the correct way. It took a few tries to realize I needed to use a while loop.

 

Another difficult part was the ifBumped section of the code. It took me a while to realize that I had to make two sub-classes from the main code, which has the if(bumped) in it,  in order for it to get information from both of the eyes on the robot.

My Main Code:

if(bumped) //Uses the Right_Bump and Left_Bump subclasses to determine it there is an obstacle in front.
{
finch.setLED(255,0,0);//Sets LED color to red
finch.get().setWheelSpeeds(100, -100);
finch.get().buzz(500,500);
}

else
{
finch.setLED(0,255,0);//Sets LED color to green
finch.get().setWheelSpeeds(50, 50);
}

My Sub-Classes:

For right_bump:

public void act()
{
super.setBumped(GreenFinch.get().isRightHit());
}

For left_bump:

public void act()
{
super.setBumped(GreenFinch.get().isLeftHit());
}

 

Leave a Reply

Your email address will not be published. Required fields are marked *