πŸš•AI +(Python)

Description

This flexible activity is designed to teach instructors how to harness large language models (LLMs) like ChatGPT to generate and refine JavaScript code that drives a four-motor robot. Each self-contained activity focuses on a core AI or robotics concept, pairing a clear learning objective with hands-on prompt exercises and real-world testing. Instructors can pick and choose which activities to run and in what order to fit their schedule and learners’ needs.

Overview

This guide covers:

  • Generating PWM commands for the ROV.

  • Understanding how PWM settings affect motor drive and direction.

  • Running user-generated Python using LLM output based on guided input.

triangle-exclamation

Bleak library

  • This library must be installed first https://github.com/hbldh/bleak

  • From the command prompt run: Run β€œpip install bleak”

RoverLLM.py

circle-check

Activity 1 – LLM Setup for Coding

Objective: Configure the LLM to output code using your ROV-specific API.

Prerequisites:

  1. Open VS Code and make a new Python file called Activity1.py. based on RoverLLM.py

  2. Copy RoverLLM.py to activity1.py

  3. Change the DeviceName (line 5) to match the Device Name of your device.

Prompt to ChatGPT:

This prompt should return back some sample code you can try.

Next Steps

  1. Replace the StartProgram function with the output from ChatGPT

  2. Execute the program in VS Code by click the run python file from the menu bar.

Activity 2 - Sensing & Reactive Behavior

Objective: User Distance to control movement

Prerequisites:

  • Open VS Code and make a new Python file called Activity2.py. based on RoverLLM.py

  • Copy RoverLLM.py to activity2.py

  • Change the DeviceName (line 5) to match the Device Name of your device.

Prompt:

Next Steps

  1. Replace the StartProgram function with the output from ChatGPT

  2. Execute the program in VS Code by click the run python file from the menu bar.

Activity 3 - Random Movements

Objective: generate an algorithm with ordered steps based on user input.

Prerequisites:

  • Open VS Code and make a new Python file called Activity3.py. based on RoverLLM.py

  • Copy RoverLLM.py to activity3.py

  • Change the DeviceName (line 5) to match the Device Name of your device.

Prompt:

Next Steps

  1. Replace the StartProgram function with the output from ChatGPT

  2. Execute the program in VS Code by click the run python file from the menu bar.

Activity 4 – Move in a Square

Objective: Generate a algorithm to move the robot in a square

Prerequisites:

  • Open VS Code and make a new Python file called Activity4.py. based on RoverLLM.py

  • Copy RoverLLM.py to activity4.py

  • Change the DeviceName (line 5) to match the Device Name of your device.

Prompt:

Next Steps

  1. Replace the StartProgram function with the output from ChatGPT

  2. Execute the program in VS Code by click the run python file from the menu bar.

Last updated