Annika SrinivasanZhengyu TaoOhm PatelZijian S
Published

ME 461 Project: Team 5

Our project is focused on enabling natural-language commands to control a robot via a large-language model (LLM).

IntermediateShowcase (no instructions)73
ME 461 Project: Team 5

Things used in this project

Hardware components

LAUNCHXL-F28379D C2000 Delfino LaunchPad
Texas Instruments LAUNCHXL-F28379D C2000 Delfino LaunchPad
×1

Software apps and online services

ChatGPT OpenAI

Story

Read more

Code

LLM Python Code

Python
This is where the user will feed their commands/prompts.
from openai import OpenAI
import matplotlib.pyplot as plt

API_KEY = " " # add your ChatGPT OpenAI API key here
MODEL_NAME = "gpt-5.1"

client = OpenAI(api_key=API_KEY)

#parameters
task_type = "circle"
# task_type :
#   "motion_planning"
#   "circle"
#   "straight_line"
#   "custom"

num_waypoints = 18 #waypoints
start = (0, 0)
goal = (1.5, 1.5)
map_size = 3

# obstacles
obstacles = [
    (1, 1),
    (0.5, 0.5),
    
]

# Circle
circle_center = (1.5, 1.5)
circle_radius = 1


# =======================================
#   Prompt
# =======================================

def build_prompt():
    obstacle_str = ", ".join([f"({ox},{oy})" for ox, oy in obstacles])

    if task_type == "motion_planning":
        return f"""
Generate a 2D motion-planning trajectory.
Map size: {map_size}  {map_size} meters.
Start: {start}
Goal: {goal}
Obstacles: {obstacle_str}
Using Greedy Search Path planning algorithom
Must start from positive X direction to the second point.
Please generate exactly {num_waypoints} waypoints (including start and end).Must be the points number I want.
The trajectory must avoid all obstacles with 0.6 m safety distance.
Points should be different.
Output ONLY CSV: x,y (no header, no explanation).
"""

    elif task_type == "circle":
        return f"""
Generate exactly {num_waypoints} waypoints such that:
1. The first waypoint must be exactly (0.00,0.00).
2. The remaining waypoints must lie on the circle with center {(0,0)} and radius {0.5}.
3. The second waypoint must be the point on the circle closest to the origin.
4. All remaining circle points must be evenly spaced along the circle.
5. Points should be different.
Format all numbers to exactly two decimals.
Output ONLY CSV: x,y (no header).

"""

    elif task_type == "straight_line":
        return f"""
Generate a straight-line trajectory from {start} to {goal}.
Output exactly {num_waypoints} evenly spaced waypoints.
Output ONLY CSV: x,y (no header).
"""

    elif task_type == "custom":
        return f"""
Generate exactly {num_waypoints} waypoints such that:
1. The first waypoint must be exactly (0.00,0.00).
The car moves forward along the positive direction of the x-axis when starting
then turns left and moves forward 0.4m, then turns right and moves forward 0.2m
Then walk in a semi-circular arc with a radius of 0.5m.
Points should be different.
Output ONLY CSV: x,y (no header).
"""

    else:
        return "Invalid task type."


# ======================

prompt = build_prompt()

response = client.chat.completions.create(
    model=MODEL_NAME,
    messages=[
        {"role": "system", "content": "You output ONLY raw CSV data."},
        {"role": "user", "content": prompt},
    ],
    temperature=0.2
)

# parses waypoints and inputs them into a CSV file format

csv_text = response.choices[0].message.content.strip()

lines = []
for line in csv_text.splitlines():
    line = line.strip().replace("`", "")
    if line and not line.startswith("```"):
        lines.append(line)

csv_clean = "\n".join(lines)
print(csv_clean)

# ===== Save to CSV file =====
with open("C:/tao19_zj/py/trajectory.csv", "w") as f:
    f.write(csv_clean)

print("Saved to trajectory.csv")


points = []
for line in csv_clean.splitlines():
    x, y = line.split(',')
    points.append((float(x), float(y)))

# ======================
#Plot
# ======================

plt.figure(figsize=(5,5))
plt.xlim(-0.5, map_size)
plt.ylim(-0.5, map_size)
plt.grid(True)

xs, ys = zip(*points)
plt.plot(xs, ys, '-o', label="Trajectory")

plt.scatter(start[0], start[1], c='green', s=80, label="Start")
plt.scatter(goal[0], goal[1], c='red', s=80, label="Goal")

for (ox, oy) in obstacles:
    plt.scatter(ox, oy, marker='x', c='black', s=120, label="Obstacle")

plt.legend()
plt.title(f"LLM Trajectory: {task_type} ({num_waypoints} points)")
plt.show()

LabVIEW

C/C++
This is the LabVIEW file for data communication.
No preview (download only).

Code Composer Studio Files

C/C++
This is the code uploaded to the robot's launchpad for control.
No preview (download only).

Credits

Annika Srinivasan
1 project • 0 followers
Zhengyu Tao
1 project • 0 followers
Ohm Patel
1 project • 0 followers
UIUC 2026, ME461 student
Zijian S
1 project • 0 followers

Comments