Having the AI make make better decisions

image

After some Ai prompting it was suggested that my robot car navigation would improve if the car did more itself with local routines and only used the AI when it could not decide so I plugged away and ended up with this code:

https://github.com/directorcia/Azure/blob/master/Iot/LLM/llm-nav-max.ino

you will see:

An ESP32 robot car drives forward until its ultrasonic sensor (mounted on a pan servo) detects an obstacle.  On each hazard event a two-tier decision pipeline fires:

1. LOCAL PLANNER  – scores three candidate maneuvers (strafe, 90° turn, and  backup+turn) using live L/F/R distance readings, front-clearance trend, and oscillation history.  If the result is “obvious” (high confidence, low risk, no repeated-trap condition) it is executed immediately without any network round-trip.


2. FOUNDRY ARBITER – when the local answer is ambiguous, or a repeated-trap is detected, a structured prompt is posted to an Azure AI Foundry Responses API endpoint.  The LLM names one candidate plan and returns a confidence score. The response is validated and sanitized; any failure falls back to the local plan.


After every maneuver the robot re-scans, records the front-clearance delta, and feeds plan quality (improved / worsened) back into the next decision cycle.

After a quick test, navigation does seem more intelligent, although it seems to make decisions a long way away and tends to get lost in wide open spaces with object far away. However, I think that if I nvested more time I could improve all that.

I have an additional idea on how I might improve the navigation in an upcoming article, but for now I think I’m pretty much done with the concept of navigation.

Leave a comment