robotics - Finch obstacle sensors is not working in java -


I'm new to Finch and Java code and I'm trying to create a new one by its sensors either left or right Moves to the right. help . Thank you

  if (suzie.isFinchLevel ()) {suzie.saySomething ("moving forward"); Suzie.sleep (1000); While (suzy.isbstakal ()) {suzie.setWheelVelocities (100,100); If (suzie.isObstacleLeftSide ()) {// right suzie.setWheelVelocities (100,2,2000); } And if (suzie.isObstacleRightSide ()) {suzie.setWheelVelocities (0, 100,2000); // left-left}}}    

It appears that you actually have to vlaues Remember that the sensor is not reached that you must first enter through the values ​​of the sensor (getObstacleSensors ()) method. Also remember that this method gives the value of each sensor as the boolean array. See Javadoc:

getObstacleSensors Public Boolean [] getObstacleSensors ()

Two elements give the value of both the barrier sensors as the boolean array. Left sensor is 0 element, and the correct sensor is the first element.

Returns: The value of left and right barrier sensor in 2 element arrays


I have done something recently that you are trying to use input from the button Actionlisteners Before implementing this, I wrote a method called "Handicap Block", which is actually executed when an obstacle occurs; This method accepts a finch object (i.e. suji) as an argument. To make this code [relatively] less wasted, the code (in the action listener) can look like this:

The implementation of the private class button listener ActionListener

  Public Zero Action Functional (ActionEvent E) {/ Get FinchTouch Handicap Sensor and Store them in an Array Boolean [] Sensor = SusieGetObstockCensor (); // Check whether any of the Fisahbot sensors detects a hindrance / it is attached in the loop for a while which is broken if the sensor is wrong (detects a barrier) (sensor [0] == False & Sensor [1] == False) {// Action Text Sets Area System.out.println ("Executing ..."); // This method tells the robot to execute an action command. Operator (suzie, -255, -85); } // Otherwise, order the rescue from the obstacle. Thaichicoloid (suzie); }   

}

I hope this works as a good starting point for you ...

T

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -