Reputation: 45
I am working on the finch robot and i am having problems using one of the functions. my_finch.getObstacleSensors().
my_finch is the robot.This is what the API says;
public boolean[] getObstacleSensors() Returns the value of both obstacle sensors as 2 element boolean array. The left sensor is the 0th element, and the right sensor is the 1st element. Returns: The values of left and right obstacle sensors in a 2 element array
What i am trying to do is retrieve the values of the right and left sensor, so that if the values are the same then the object it is detecting has not moved, but if the values changed then the object has moved and the robot can continue to follow.
I am having problem with recovering the data from the boolean array. Heres what i tried:
boolean[] Sense;
System.out.println(Sense[1]);
Output: False....
System.out.println(my_finch.getObstacleSensors());
Output: [Z@5f150435
[Z@1c53fd30
[Z@50cbc42f
[Z@75412c2f
[Z@282ba1e
[Z@13b6d03
ECT.
First i was just trying to figure out how to use this function, or should i try something different to see if the object has moved or not?
Upvotes: 0
Views: 296
Reputation: 131
your problem is casued because the array object doesn't have a toString method and that's why your System.out.println(my_finch.getObstacleSensors());
doesn't print the boolean values.
try System.out.println(Arrays.toString(my_finch.getObstacleSensors()));
Upvotes: 2