1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 | int sonar_id, total_sonars; // If at least one sensor has a hit if (sonars.oneHasHit()) { // Find out how many sonars are on the robot total_sonars = sonars.getNumSensors(); // Iterate through each sonar for ( sonar_id = 0 ; sonar_id < total_sonars ; sonar_id++ ) { // Does this one have a hit? if (sonars.hasHit(sonar_id)) { // Emit the details (angle, range) System.out.println( "Sonar hit at angle " + sonars.getAngle(i) + " at range " + sonars.getMeasurement(i) ); } } } |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public int TakeStep() { Vec2 ball; long T; T = abstract_robot.getTime(); // Get the vector to the ball ball = abstract_robot.getBall(T); // Point ourselves to it abstract_robot.setSteerHeading(T, ball.t); // Go to it (maximum speed) abstract_robot.setSpeed(T, 1.0); // If we can kick it, do so! if (abstract_robot.canKick(T)) abstract_robot.kick(T); return(CSSTAT_OK); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |