FixTheRobot Explore Robotics / Robot Learning / M7 / M7-L2

This lab works on phones, but writing code is much easier on a laptop.

Robot Learning · Model-Based Robot Learning · M7-L2 · Intermediate

Plan with Random Shooting

Experiment log · Scout at Meridian General Hospital

Experiment log, Meridian General Hospital, logistics corridor. With the dynamics fitted (lab M7-L1), Scout no longer needs a trained policy to reach the pharmacy: it can imagine futures. At every moment it will try a few dozen random command sequences in its head, see where each would lead, and carry out the best.

You will write the three pieces of that planner: the cost that says which imagined future is better (including a hefty penalty for hitting the pillar), the loop that rolls every candidate through the model and picks the cheapest, and the cross-entropy refit that concentrates the next batch of guesses around the best ones. JavaScript supplies the candidates and then drives your chosen plan on the real floor.

Your task

    Simulation
    solution.pyLoading Python…
    Ctrl+Enter runs
    What Python can I use?

    Plain Python with math and heapq. Your code runs in a background worker: an endless loop is stopped after a few seconds and the page stays usable. It runs in your browser and is never sent anywhere.

    Hints

    What this lab teaches

    Stage 1 writes the plan cost used throughout the module: goal distance of the predicted states, a per-step collision penalty and a small action cost. Stage 2 writes random shooting: roll each candidate out from the current state, score it, keep the cheapest, and see the chosen plan executed on a floor that differs slightly from the model. Stage 3 writes the cross-entropy refit: choose the lowest-cost elites, then compute the new mean and the floored population standard deviation per time step and axis.

    Grading is exact where there is one right answer (costs, the chosen index, the refit statistics) and behavioural where the floor decides (the executed plan must avoid the pillar and end closer to the goal). Hidden checks use other start states, candidate batches and floor parameters.

    Theory for this lab

    Model-Based Robot Learning labs

    1. M7-L1: Fit the Dynamics
    2. M7-L2: Plan with Random Shooting: this lab.
    3. M7-L3: When the Model Lies

    Educational simplification: a point-mass model whose parameters are within about 3% of the floor, one obstacle, plans of 12 steps and batches of 40 candidates (the module reference planner replans at every step with 48 samples and three CEM rounds). Real planners also bound accelerations and check the path between predicted states.

    Get the next lab

    Get notified when new robotics labs are released. One email per new lab, nothing else.