A Java controller that guides a Pioneer 3-DX through an obstacle arena using goal seeking and wall following.
This project connects proximity sensing, differential-drive motion, and a navigation state machine in a Webots simulation. The robot turns toward a target, follows walls when an obstacle blocks its route, and stops when it reaches the goal tolerance.
| Component | Responsibility |
|---|---|
MyLab5Controller.java |
Switches between GO_TO_GOAL and WALL_FOLLOW; checks goal distance |
PioneerNav2.java |
Controls wheel velocities, forward motion, turns, and wall following |
PioneerProxSensors1.java |
Reads 16 sonar sensors and draws the sensor display |
Pose.java |
Represents position and heading |
bugworld23.wbt |
Defines the arena, obstacles, robot, camera, and display |
The navigation layer uses a proportional/derivative wall-following controller; the integral gain is zero in the committed source. Position comes from Webots' Supervisor API, while wheel position sensors are used to report distance travelled.
The world declares Webots R2022b and references that release's robot and object definitions. Use a compatible Webots installation with its Java controller support and a matching JDK.
The repository follows the Webots project layout:
webots-navigation/
├── worlds/
│ └── bugworld23.wbt
└── controllers/
└── MyLab5Controller/
├── MyLab5Controller.java
├── PioneerNav2.java
├── PioneerProxSensors1.java
└── Pose.java
- Clone or download the repository, preserving its folders.
- Open
worlds/bugworld23.wbtin Webots. - Build the
MyLab5ControllerJava controller using Webots' controller build support. - Start the simulation and inspect the sensor display and console output.
The world selects MyLab5Controller and enables Supervisor mode. Generated .class files are excluded; build from the Java sources with your installed Webots/JDK tools. Source and world contents are preserved by this layout change, and all README file links have been checked. Webots is not installed in the repair environment, so controller compilation and a fresh simulator run remain unverified. See the Webots controller guide for the simulator's build/run workflow.
The heading calculations can be checked without Webots:
tests/run_pose_tests.shThis compiles Pose and its standalone regression test into a temporary directory. It checks multi-turn normalization, the -pi/pi boundary, shortest heading differences, constructors and setters, and rejection of non-finite headings. It does not compile or validate the Webots-dependent controller or run the simulator.
The controller defines a starting pose at (-4.5, 3.0) and a target at approximately (2.75, -3.26). It stops within 0.05 m of the target. Change the target in MyLab5Controller.java, or edit the obstacles in the world, to explore how the navigation states interact.
This is a simulation of reactive navigation with access to ground-truth position. It does not implement SLAM, and the heuristic wall-following transitions do not establish shortest-path or universal reachability guarantees.
The Java source headers credit Terry Payne for the laboratory controller and supporting navigation/sensor classes. Those attributions are retained; the repository builds on that teaching scaffold.