Cognitive Robotics Practical Simulation App

This single HTML app converts the lecture ideas into hands-on mini labs. It covers cognition, brain-body-environment interaction, Bayesian reasoning, anticipation, reinforcement learning, sensorimotor coordination, affordances, tool use and cognitive architectures.

Offline HTMLCanvas simulationsNo external librariesBuilt for teaching/demoHigh contrast / reverse / B&W modesFont accessibilityTalkBack read aloud

Perceive

Sense the world with noisy visual/tactile data, then select information useful for action.

Act

Move the body, reach, push, grasp, use tools and update the world through actions.

Learn

Improve models from experience using data, incremental updates and reinforcement signals.

Anticipate

Predict future states so the robot can act before reaction alone becomes too late.

Adapt

Change internal parameters when the body, task or environment changes.

Why this app?

The lectures describe cognitive robots as autonomous systems that perceive, act, adapt, learn and anticipate. Here those words become visible: you can change noise, delays, learning rates, reward structure, body growth and object properties, then watch the robot behave differently.

What to demonstrate in class

  • Reaction versus anticipation in catching.
  • Bayesian inference from uncertain evidence.
  • How Q-learning gradually improves action selection.
  • How affordances emerge through exploration.
  • How a cognitive architecture connects modules into flexible behaviour.

Suggested teaching flow

Start with the Cognitive Loop lab, then use Bayesian Network for uncertainty, Anticipation for prediction, Reinforcement Learning for trial-and-error, Sensorimotor Reaching for embodied coordination, Affordance Learning for object-action-effect relations, Tool Use for planning, and Cognitive Architecture to connect everything.

Lab 1 - Cognitive loop: perceive, act, adapt, learn, anticipate

A robot follows a moving target. It receives noisy perception, predicts where the target will be next, acts, and adapts its internal estimate.

Brain-body-environment
Closed perception-action looplive target, measurement, belief, prediction and robot action
True targetNoisy sensor measurementInternal beliefPredicted future positionRobotRobot-to-target tracking direction

Controls

0tracking error
learningcurrent process
Concept: cognition is not a single box. It is a loop where sensing changes action, action changes sensing, and learning improves future action.

Lab 2 - Bayesian network for uncertain robot perception

Select visual evidence and an action. The network computes likely object type and predicted effect. This simulates how a robot can combine uncertain evidence instead of using one fixed rule.

Probability + inference
Bayesian causal graphevidence → belief → action effect

Evidence

Ballmost likely object
rollpredicted effect
Try: round + smooth + push. Then change action to grasp. The same object can afford different actions with different effects.

Probability table — what the Bayesian network is calculating

The table below uses the same prior probabilities and evidence likelihoods as the simulation. Posterior probability is the updated belief after combining the selected shape, size and surface evidence. The values change whenever you change an evidence selector or the robot action.

Select evidence to see the updated belief and predicted effect.

Lab 3 - Anticipation: reaction is not enough

Two robots try to catch a falling ball. The reaction-only robot goes to the measured current location. The anticipatory robot predicts where the ball will be after its control delay.

Internal model
Catching comparisonreaction vs prediction

Controls

0reaction catches
0anticipation catches
When speed or delay is high, pure perception-reaction fails more often. Anticipation compensates by predicting future state.

Lab 4 - Reinforcement learning: Q-learning grid robot

A robot explores a grid, receives rewards and penalties, and gradually learns a policy. Use episodes to see value estimates and action arrows develop.

Trial-and-error learning
Q-learning grid worldgreen goal, red hazards, blue robot

Learning parameters

0episodes
0last reward
Arrows show the best learned action from each state. At first they are random; after training they point toward reward while avoiding hazards.

How the reinforcement-learning simulation works

This grid world represents a robot learning a navigation policy through trial and error. The robot starts at the bottom-left, must reach the GOAL, and should avoid the HAZARD cells. There is deliberately no pre-written route: the policy is built from reward feedback.

1. Choose an action

At each state the robot chooses Up, Right, Down or Left. With probability ε it explores a random action; otherwise it selects the action with the highest current Q-value.

2. Receive feedback

Reaching the goal gives +10, entering a hazard gives −8, and every ordinary move gives −0.1. This makes shorter, safer routes more useful.

3. Update Q-values

The simulation applies Q-learning: Q(s,a) is moved toward the received reward plus the discounted value of the best next action. α controls how strongly new experience changes the estimate.

4. Look ahead

γ controls how much future rewards matter. A high γ encourages the robot to value actions that lead toward a useful future state rather than only immediate reward.

5. Learn a policy

The arrow in each ordinary cell shows the currently best-valued action. Early arrows can be uninformative because all Q-values start at zero; after training, useful directions emerge.

6. What the goal demonstrates

The learning goal is not memorising a fixed path. It is demonstrating how repeated interaction and reward can produce an improving action-selection policy.

What to observe: train several times, then compare the arrows and Q-values with the untrained grid. Increase ε to make behaviour more exploratory, increase α to make new feedback change learning faster, and change γ to alter the importance of future rewards.

Lab 5 - Sensorimotor development and gaze-driven reaching

A two-link robot arm learns to reach a target. The movement has a fast ballistic phase and a visually guided correction phase. Change growth and noise to see adaptation.

Action-perception loop
Gaze, reaching and body modelclick canvas to set target

Controls

0hand-target error
idlephase
This demonstrates developmental coordination: eyes fixate the object, then the arm reaches, and feedback corrects errors caused by noise or body changes.

Understanding the sensorimotor reaching simulation

This simulation represents an embodied robot arm coordinating visual perception, body geometry and movement. The gaze marker represents visual attention to the target, the two-link arm represents the body, and the green target represents the object the hand should reach.

Parameters and their effect on behaviour
ParameterRange / current meaningWhat it changesWhat to look for
Body growth / arm length0.70×–1.35×Scales both arm links and changes the reachable workspace.Changing body size creates a mismatch between the current body and the internal body model.
Visual noise0–55 pxAdds random error to the target position used by the controller.Higher noise makes the visual estimate less stable, so corrections become more variable.
Adaptation rate0.01–0.80Controls how quickly the internal arm-scale estimate moves toward the actual body scale.Higher adaptation lets the internal model adjust faster after body-growth changes.
Hand-target errorLive pixelsDistance between the actual hand position and the true target.Lower error means the arm is successfully coordinating perception and action.
PhaseIdle / ballistic / visual correctionShows which part of the reaching movement is active.The movement begins with a faster ballistic phase and then uses visual feedback for final correction.

Ballistic phase

The arm initially moves quickly toward the visually estimated target. This represents a fast, largely pre-planned part of reaching.

Visual correction

After the initial movement, the controller uses the noisy visual estimate repeatedly to refine the joint angles and reduce final positioning error.

Performance

The live error and phase indicators show whether the hand is converging on the target and whether the controller is still moving or has completed the reach.

Performance summary will update while the arm is moving.

Lab 6 - Affordance learning by exploration

Choose an object and an action, then let the robot try it. The robot updates an object-action-effect table from experience.

Object-action-effect
Affordance exploration tableprobabilities learned from trials

Experiment

0trials
nonelast effect
An affordance is not only a property of an object. It depends on the relation between object, action, robot body and environment.

Understanding the affordance-learning simulator

What the simulator represents: This simulator models how a robot can discover affordances by interacting with different objects. An affordance is the action possibility that emerges from the relationship between the object, the chosen action, the robot's capabilities and the environment. Instead of assuming the correct outcome is known in advance, the robot builds experience from repeated trials.

How it works

Select an object and an action, such as pushing a ball or grasping a cup. Each trial samples an outcome from the simulator's object-action model. The result is added to the robot's experience table, and the displayed effect probabilities are recalculated from the accumulated trials.

What it represents

The table is a simplified learned model of the relationship object → action → effect. Different objects respond differently to the same action, so the robot must learn which interactions are useful rather than treating every object in the same way.

Key outcome to observe

Watch the effect probabilities become more informative as the number of trials increases. The important outcome is convergence toward a useful prediction of what an action will do. Use Auto explore to see how experience gradually turns uncertain interaction into a more reliable affordance model.

Key observation: Compare the same action on different objects. The learned probabilities should differ, demonstrating that an affordance is relational rather than simply a fixed property stored on the object.

Lab 7 - Tool use and planning with affordances

The robot must achieve a desired effect. It can select direct reach, push, or a tool. Planning uses predicted effects of object-tool-action combinations.

Planning from affordances
Tabletop tool-use plannerselect goal effect and plan

Task

-selected action
-predicted success
This is a simplified version of using affordances for action planning: choose the action/tool most likely to produce the desired effect.

Understanding the tool-use planning simulator

What the simulator represents: This simulator demonstrates how a robot can use learned or predicted affordances to choose actions and tools that are likely to produce a desired effect. The robot starts with a task goal, considers the available tool, and selects a simplified action plan based on the predicted usefulness of the available object-tool-action combination.

How it works

Choose a goal such as bringing an object closer, moving it right, or lifting it. Then choose a long stick, hook, or no tool. When Plan action is pressed, the planner evaluates the available combination and returns an action, a predicted success percentage and a short reason. The canvas then animates the planned effect.

What it represents

This is a simplified model of planning from affordances: the robot is not only asking “what action can I perform?” but “which action, with which tool, is likely to create the effect I need?” Tool use therefore extends the robot's reachable actions beyond direct body interaction.

Key outcome to observe

Change only the available tool while keeping the goal the same. Observe that the selected action and predicted success can change. The key outcome is goal-directed action selection based on predicted effects, rather than choosing an action randomly or using a single fixed behaviour.

Key observation: A tool is useful because it changes the set of achievable effects. Compare “No tool”, “Long stick” and “Hook tool” for the same goal and examine how the plan changes.

Lab 8 - Cognitive architecture: connecting modules

Follow a high-level command through natural language understanding, visual object understanding, affordance perception, action planning and action execution.

High → mid → low level
Architecture flowclick run to animate module activation

Command

0/6module step
idlesystem state
A cognitive architecture acts as glue: it links perception, memory, language, planning and motor execution into one behaviour.

Understanding the cognitive-architecture simulator

What the simulator represents: This simulator shows how multiple cognitive modules can be connected into one robot behaviour. A high-level human instruction is progressively transformed into goals and memory, visual object understanding, affordance perception, action planning and finally low-level action execution. It is a teaching model of the flow between cognition, perception and behaviour rather than a complete robotic operating system.

How it works

Select a command and an architecture style, then run the flow. The modules activate sequentially from high level to mid level to low level. At each step, the simulator displays the corresponding interpretation—for example, detecting an object, identifying its affordance, planning the action and executing the movement.

What it represents

The architecture acts as the coordination layer between language, perception, memory, affordance reasoning, planning and motor control. The three styles provide simplified conceptual views: cognitivist emphasises a fixed symbolic flow, emergent emphasises adaptive self-organisation, and hybrid combines symbolic and adaptive modules.

Key outcome to observe

Watch the command move through the complete chain instead of jumping directly from language to motor output. The key outcome is functional integration of modules: a high-level goal becomes an executable sequence of lower-level actions through intermediate representations and decisions.

Key observation: Compare the three architecture styles using the same command. Focus on which parts of the process are represented as explicit reasoning, adaptive interaction, or a combination of both.

Revision quiz and viva prompts

Use this section after the simulations to check understanding. Click an answer to see feedback.

Exam practice

Quiz

Viva/practical prompts

  • Explain why a robot needs anticipation using the catching lab.
  • Describe how a Bayesian network represents relationships between sensory evidence, actions and effects.
  • Use the reaching lab to explain open-loop ballistic movement and closed-loop visual correction.
  • Explain affordance learning as object-action-effect prediction.
  • Compare cognitivist, emergent and hybrid cognitive architectures.

Source mapping inside the app

Week 1 ideas are used in the overview and loop labs; Week 2 ideas drive Bayesian reasoning; Week 3 supports anticipation, learning and RL; Week 5 supports sensorimotor learning and affordances; Week 6 supports the architecture and tool-use/planning labs.

Exam answer checker + full paper practice

Choose the exact past-paper sub-question, type your answer or select an MCQ, then check model answer points. MCQ options shuffle every time the question loads or the file is refreshed.

Fixed input + paper mode

Past-paper question controls

Question

Choose a paper question. You will be able to type in the box or select an MCQ option.

Progress

0checked
0%average
0paper items
Important: written-answer marking uses key concept matching. It checks whether the main ideas are present and then shows model answer points, so students can rewrite their answer under the word limit.

What changed

  • MCQs now use real radio buttons and can be selected.
  • Written/numerical questions now always show an editable answer box.
  • Exam checker contains full past-paper sub-questions, not only MCQs.
  • Revision quiz has a much larger MCQ bank with shuffled answers.