Skip to content

Robot 2 #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 87 commits into
base: colin/grid-search
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
c34ba2d
Reorg head of file
sharlaon Oct 22, 2024
c8fc341
Fix typo
sharlaon Oct 23, 2024
d71404f
Add viz plans
sharlaon Oct 23, 2024
370ca48
Reorg noisy sensors
sharlaon Oct 23, 2024
a59259a
Add likelihood optimization and commentary
sharlaon Oct 23, 2024
d058b5b
Cleanup
sharlaon Oct 25, 2024
1fe08c2
Bug fix
sharlaon Oct 25, 2024
ce24f6a
Fix performance regression
sharlaon Oct 28, 2024
ba9d0d6
Nit
sharlaon Oct 28, 2024
cc6792e
Bug fix
sharlaon Oct 28, 2024
53c6005
Add comment
sharlaon Oct 28, 2024
f211b07
Clean up world map
sharlaon Oct 28, 2024
1e44687
Add map discretization into rooms and doorways
sharlaon Oct 29, 2024
ca23df8
Nit
sharlaon Oct 29, 2024
8e7fc38
Add goals and tasks
sharlaon Oct 29, 2024
c8b9ac2
Add goals prior
sharlaon Oct 29, 2024
92199f8
Wrap around room point lists
sharlaon Oct 30, 2024
a3320b6
Manually simplify sensor distance
sharlaon Oct 30, 2024
20fefd1
Project point onto map discretization
sharlaon Oct 30, 2024
8eb4c6d
Nits
sharlaon Oct 30, 2024
c1ca1ea
Nit
sharlaon Nov 1, 2024
6d94d5e
Move up random sample poses
sharlaon Nov 1, 2024
1c24351
Move up `make_circle`
sharlaon Nov 1, 2024
8c02b28
Vestigial bug
sharlaon Nov 1, 2024
e1959a4
Nit
sharlaon Nov 1, 2024
92de907
Nit
sharlaon Nov 1, 2024
194e47c
Rename `locate` to `locate_discrete`
sharlaon Nov 1, 2024
003124b
Nit
sharlaon Nov 1, 2024
5293d91
Refactor `doorways` into Dict
sharlaon Nov 1, 2024
d8689b3
Change framerate
sharlaon Nov 1, 2024
35df1f8
Add coarse planning
sharlaon Nov 1, 2024
484f2db
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 1, 2024
9cdc8ad
Merge pull request #16 from probcomp/goal-inference
sharlaon Nov 1, 2024
a7fc36f
Sequential Importance Sampling (SIS) for localization (#21)
littleredcomputer Jan 27, 2025
2b5a0e8
upgrade genjax; start work on grid search
littleredcomputer Oct 21, 2024
32aaaab
four-way plot
littleredcomputer Oct 22, 2024
3b027dd
doc and graphics fixes
littleredcomputer Oct 22, 2024
ebc205c
wip
littleredcomputer Oct 25, 2024
a476b2e
get grid improver working
littleredcomputer Nov 6, 2024
0b3cb4c
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 6, 2024
cafe8a8
- prepend `noop_contro`l to `robot_inputs['controls']` once and for all
littleredcomputer Nov 6, 2024
37b986f
- add some missing cell dividers back
littleredcomputer Nov 7, 2024
5141d49
more visualization, doc touchups
littleredcomputer Nov 12, 2024
638be10
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 12, 2024
7fca2af
update ipynb version
littleredcomputer Nov 12, 2024
4d79ab9
notes from pair with @huebert
littleredcomputer Nov 18, 2024
3b50801
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 18, 2024
bdfe521
use genstudio v2024.11.006
mhuebert Nov 8, 2024
cc4316e
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Nov 8, 2024
e7f70dd
use genstudio v2024.11.012
mhuebert Nov 12, 2024
48ac7a2
fix heading modified
mhuebert Nov 19, 2024
51699b3
initial pose angle slider
mhuebert Nov 28, 2024
8a0004b
wip: drawing canvas works
mhuebert Nov 29, 2024
488d60a
new narrative approach
mhuebert Nov 29, 2024
15725fb
flesh out reality.py
mhuebert Nov 29, 2024
0ad66b7
wall intersection works
mhuebert Nov 29, 2024
a698bd3
add wall collision
mhuebert Nov 29, 2024
f22618d
noise sliders work
mhuebert Nov 30, 2024
85368a6
show possible paths, without collision implemented
mhuebert Nov 30, 2024
fc7eb21
hide true path
mhuebert Nov 30, 2024
b6ac6d3
simplify planned path
mhuebert Nov 30, 2024
d4929c2
use motion settings when sampling possible paths
mhuebert Nov 30, 2024
74cc342
functional approach
mhuebert Nov 30, 2024
50eccba
allow no walls
mhuebert Dec 1, 2024
219374d
layout
mhuebert Dec 1, 2024
765b486
jax jit
mhuebert Dec 1, 2024
7cd2f4b
dynamic sensor count
mhuebert Dec 1, 2024
efd57a9
use masking for sensor readings
mhuebert Dec 1, 2024
860955b
fixed wall threshold issue
mhuebert Dec 1, 2024
0f5c204
key scrubber
mhuebert Dec 1, 2024
1324511
genstudio update
mhuebert Dec 1, 2024
f040d43
improved key scrubber
mhuebert Dec 2, 2024
a898409
consolidate into where_am_i.py
mhuebert Dec 2, 2024
ab53ef5
rotating sensor rays
mhuebert Dec 2, 2024
7e658a5
simplify
mhuebert Dec 2, 2024
033814e
sample true and possible paths together
mhuebert Dec 2, 2024
5a2d1dd
smaller heading noise
mhuebert Dec 2, 2024
497ee25
mouse control of sensor view
mhuebert Dec 2, 2024
bc829bd
heading noise control, more paths
mhuebert Dec 2, 2024
715c870
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 2, 2024
3457e65
revert changes
mhuebert Dec 2, 2024
c360acc
plot order
mhuebert Dec 4, 2024
e2fedad
formatting / ruff
mhuebert Dec 4, 2024
c78f858
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Dec 4, 2024
5257b31
robot viz in genjax (GEN-884) (#20)
mhuebert Jan 27, 2025
538f3ae
attempt to fix localization tutorial merge
mhuebert Jan 27, 2025
8d960a7
bump genstudio
mhuebert Jan 27, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,283 changes: 0 additions & 2,283 deletions example_20_program.json

This file was deleted.

Empty file.
2,735 changes: 2,735 additions & 0 deletions genjax-localization-tutorial/probcomp-localization-tutorial.ipynb

Large diffs are not rendered by default.

907 changes: 589 additions & 318 deletions genjax-localization-tutorial/probcomp-localization-tutorial.py

Large diffs are not rendered by default.

46 changes: 46 additions & 0 deletions goals.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"tasks": {
"task1": {
"p": [
15.0,
12.0
],
"r": 0.5
},
"task2": {
"p": [
3.0,
7.0
],
"r": 0.5
},
"task3": {
"p": [
10.0,
12.0
],
"r": 0.5
},
"task4": {
"p": [
18.0,
2.0
],
"r": 0.5
}
},
"goals": {
"goal1": {
"task1": []
},
"goal2": {
"task2": [],
"task3": [
"task2"
]
},
"goal3": {
"task4": []
}
}
}
2,066 changes: 1,116 additions & 950 deletions poetry.lock

Large diffs are not rendered by default.

928 changes: 603 additions & 325 deletions probcomp-localization-tutorial.jl

Large diffs are not rendered by default.

11 changes: 7 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
[tool.poetry]
name = "genjax-localization-tutorial"
name = "genjax_localization_tutorial"
version = "0.1.0"
description = ""
authors = ["Matthew Huebert <mhuebert@gmail.com>"]
readme = "README.md"

package-mode = false
packages = [
{ include = "robot_2" }
]

[tool.poetry.dependencies]
python = ">=3.11,<3.13"
jupytext = "^1.16.1"
genjax = {version = "0.5.0.post30.dev0+2df4f579" , source = "gcp" }
genstudio = {version = "2024.07.29.2335", source = "gcp"}
genjax = {version = "0.8.0", source = "gcp" }
genstudio = "2025.1.9"
ipykernel = "^6.29.3"
matplotlib = "^3.8.3"
anywidget = "^0.9.7"
watchfiles = "^0.21.0"
markdown = "^3.6"
pytest = "^8.3.3"

[[tool.poetry.source]]
name = "gcp"
Expand Down
Empty file added robot_2/__init__.py
Empty file.
290 changes: 290 additions & 0 deletions robot_2/bench.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,290 @@
# %%
import jax.numpy as jnp
import time
from robot_2.where_am_i import (
RobotCapabilities,
simulate_robot,
World,
walls_to_jax,
PRNGKey,
)
import jax.random

# Benchmark State:
# Walls:
walls = [
[0, 0, 0],
[10, 0, 0],
[10, 0, 0],
[10, 10, 0],
[10, 10, 0],
[0, 10, 0],
[0, 10, 0],
[0, 0, 0],
[8.125, 9.03125, 1974574552],
[7.875, 9.0625, 1974574552],
[7.53125, 9.0625, 1974574552],
[7.09375, 9.09375, 1974574552],
[6.8125, 9.09375, 1974574552],
[6.5, 9.125, 1974574552],
[6.1875, 9.125, 1974574552],
[5.71875, 9.15625, 1974574552],
[5.40625, 9.15625, 1974574552],
[5.09375, 9.15625, 1974574552],
[4.75, 9.15625, 1974574552],
[4.4375, 9.125, 1974574552],
[4, 9.09375, 1974574552],
[3.71875, 9.0625, 1974574552],
[3.46875, 9.03125, 1974574552],
[3.21875, 9, 1974574552],
[2.96875, 8.9375, 1974574552],
[2.5625, 8.84375, 1974574552],
[2.09375, 8.75, 1974574552],
[1.71875, 8.625, 1974574552],
[1.75, 8.34375, 1974574552],
[2.03125, 8.25, 1974574552],
[2.34375, 8.1875, 1974574552],
[2.71875, 8.15625, 1974574552],
[3.0625, 8.125, 1974574552],
[3.40625, 8.09375, 1974574552],
[3.96875, 8.0625, 1974574552],
[4.3125, 8.03125, 1974574552],
[4.625, 8.03125, 1974574552],
[4.90625, 8, 1974574552],
[5.3125, 8, 1974574552],
[5.59375, 8, 1974574552],
[5.875, 7.9375, 1974574552],
[6.15625, 7.875, 1974574552],
[6.4375, 7.75, 1974574552],
[6.6875, 7.59375, 1974574552],
[6.8125, 7.375, 1974574552],
[6.6875, 7.15625, 1974574552],
[6.40625, 7, 1974574552],
[5.78125, 6.875, 1974574552],
[5.4375, 6.8125, 1974574552],
[5.09375, 6.75, 1974574552],
[4.34375, 6.625, 1974574552],
[3.90625, 6.5625, 1974574552],
[3.65625, 6.5, 1974574552],
[3.1875, 6.4375, 1974574552],
[2.625, 6.28125, 1974574552],
[2.65625, 5.96875, 1974574552],
[2.9375, 5.84375, 1974574552],
[3.25, 5.78125, 1974574552],
[3.53125, 5.75, 1974574552],
[4.03125, 5.71875, 1974574552],
[4.46875, 5.6875, 1974574552],
[5.21875, 5.6875, 1974574552],
[5.75, 5.6875, 1974574552],
[6.0625, 5.6875, 1974574552],
[6.3125, 5.6875, 1974574552],
[6.5625, 5.65625, 1974574552],
[6.59375, 5.3125, 1974574552],
[6.375, 5.1875, 1974574552],
[6, 5.0625, 1974574552],
[5.3125, 4.9375, 1974574552],
[4.9375, 4.875, 1974574552],
[4.1875, 4.8125, 1974574552],
[3.875, 4.75, 1974574552],
[3.46875, 4.71875, 1974574552],
[3.0625, 4.65625, 1974574552],
[2.75, 4.59375, 1974574552],
[2.46875, 4.5, 1974574552],
[2.78125, 4.1875, 1974574552],
[3.15625, 4.125, 1974574552],
[3.53125, 4.0625, 1974574552],
[4, 4, 1974574552],
[4.46875, 3.9375000000000004, 1974574552],
[5.25, 3.8749999999999996, 1974574552],
[5.75, 3.84375, 1974574552],
[6, 3.84375, 1974574552],
[6.28125, 3.84375, 1974574552],
[6.75, 3.84375, 1974574552],
[6.5, 3.53125, 1974574552],
[6.25, 3.5, 1974574552],
[5.875, 3.4375, 1974574552],
[5.59375, 3.4062499999999996, 1974574552],
[5.0625, 3.375, 1974574552],
[4.625, 3.375, 1974574552],
[3.9375, 3.34375, 1974574552],
[2.875, 3.3125000000000004, 1974574552],
[1.75, 3.1562500000000004, 1974574552],
[1.5, 3.0625, 1974574552],
[1.53125, 2.7812499999999996, 1974574552],
[1.8125, 2.65625, 1974574552],
[2.0625, 2.6249999999999996, 1974574552],
[2.625, 2.5, 1974574552],
[2.875, 2.4687499999999996, 1974574552],
[3.375, 2.40625, 1974574552],
[3.9375, 2.3750000000000004, 1974574552],
[4.8125, 2.34375, 1974574552],
[5.34375, 2.34375, 1974574552],
[5.875, 2.34375, 1974574552],
[6.34375, 2.34375, 1974574552],
[6.59375, 2.34375, 1974574552],
[7.15625, 2.34375, 1974574552],
[7.4375, 2.28125, 1974574552],
[7.1875, 2.03125, 1974574552],
[6.75, 1.9374999999999998, 1974574552],
[6.4375, 1.875, 1974574552],
[5.59375, 1.7812499999999998, 1974574552],
[5.125, 1.7812499999999998, 1974574552],
[4.625, 1.7812499999999998, 1974574552],
[3.96875, 1.71875, 1974574552],
[3.4375, 1.6562500000000002, 1974574552],
[3.125, 1.5937500000000004, 1974574552],
[2.71875, 1.4687499999999998, 1974574552],
[2.40625, 1.3437500000000002, 1974574552],
[2.0625, 1.2187499999999996, 1974574552],
[2.5, 1.0312500000000002, 1974574552],
[2.84375, 1.0312500000000002, 1974574552],
[3.375, 0.9999999999999998, 1974574552],
[3.96875, 0.9687500000000004, 1974574552],
[4.6875, 0.9375, 1974574552],
[5.21875, 0.9375, 1974574552],
[5.84375, 0.9687500000000004, 1974574552],
[6.4375, 1.0312500000000002, 1974574552],
[7, 1.1562499999999998, 1974574552],
[7.34375, 1.2187499999999996, 1974574552],
[7.40625, 1.25, 1974574552],
]

# Robot Path:
robot_path = [
[2.5, 0.2500000000000002, 1097479840],
[3.03125, 0.2500000000000002, 1097479840],
[3.625, 0.2500000000000002, 1097479840],
[4.125, 0.2500000000000002, 1097479840],
[4.625, 0.2500000000000002, 1097479840],
[5.375, 0.21874999999999978, 1097479840],
[5.90625, 0.18750000000000044, 1097479840],
[6.4375, 0.18750000000000044, 1097479840],
[6.96875, 0.18750000000000044, 1097479840],
[7.46875, 0.28124999999999956, 1097479840],
[7.9375, 0.46875, 1097479840],
[8, 0.9999999999999998, 1097479840],
[7.65625, 1.40625, 1097479840],
[7.15625, 1.5625, 1097479840],
[6.5625, 1.5625, 1097479840],
[6, 1.5312499999999996, 1097479840],
[5.5, 1.5000000000000002, 1097479840],
[4.9375, 1.40625, 1097479840],
[4.40625, 1.3749999999999996, 1097479840],
[4.9375, 1.3437500000000002, 1097479840],
[5.46875, 1.4375000000000004, 1097479840],
[6.0625, 1.4375000000000004, 1097479840],
[6.625, 1.4687499999999998, 1097479840],
[7.1875, 1.5000000000000002, 1097479840],
[7.65625, 1.71875, 1097479840],
[7.8125, 2.2187500000000004, 1097479840],
[7.71875, 2.71875, 1097479840],
[7.25, 2.90625, 1097479840],
[6.6875, 3.03125, 1097479840],
[6.03125, 3.125, 1097479840],
[5.4375, 3.125, 1097479840],
[4.875, 3.0625, 1097479840],
[4.28125, 3.03125, 1097479840],
[3.71875, 3.0000000000000004, 1097479840],
[4.34375, 2.96875, 1097479840],
[4.96875, 2.96875, 1097479840],
[5.65625, 3.0000000000000004, 1097479840],
[6.25, 3.0000000000000004, 1097479840],
[7.09375, 3.0000000000000004, 1097479840],
[7.75, 3.03125, 1097479840],
[8.25, 3.125, 1097479840],
[8.1875, 3.6875, 1097479840],
[7.59375, 4, 1097479840],
[6.96875, 4.21875, 1097479840],
[6.375, 4.375, 1097479840],
[5.875, 4.4375, 1097479840],
[5.375, 4.5, 1097479840],
[6, 4.5625, 1097479840],
[6.53125, 4.6875, 1097479840],
[7.0625, 4.78125, 1097479840],
[7.4375, 5.1875, 1097479840],
[7.1875, 5.6875, 1097479840],
[6.75, 6.03125, 1097479840],
[6.125, 6.34375, 1097479840],
[5.59375, 6.46875, 1097479840],
[5.0625, 6.46875, 1097479840],
[5.59375, 6.46875, 1097479840],
[6.78125, 6.5625, 1097479840],
[7.3125, 6.65625, 1097479840],
[7.9375, 6.90625, 1097479840],
[8.15625, 7.40625, 1097479840],
[7.6875, 7.71875, 1097479840],
[7.09375, 7.90625, 1097479840],
[6.46875, 8.0625, 1097479840],
[5.96875, 8.15625, 1097479840],
[5.375, 8.1875, 1097479840],
[4.6875, 8.3125, 1097479840],
[4.1875, 8.34375, 1097479840],
[4.6875, 8.4375, 1097479840],
[5.46875, 8.46875, 1097479840],
[5.96875, 8.46875, 1097479840],
[6.53125, 8.46875, 1097479840],
[7.09375, 8.46875, 1097479840],
[7.59375, 8.53125, 1097479840],
[8.15625, 8.625, 1097479840],
[8.65625, 8.8125, 1097479840],
[8.28125, 9.34375, 1097479840],
[7.75, 9.4375, 1097479840],
[7.15625, 9.5, 1097479840],
[6.625, 9.5, 1097479840],
[6, 9.5, 1097479840],
[5.375, 9.53125, 1097479840],
[4.8125, 9.53125, 1097479840],
[4.1875, 9.53125, 1097479840],
[3.5625, 9.4375, 1097479840],
[3, 9.4375, 1097479840],
[2.46875, 9.40625, 1097479840],
[1.84375, 9.34375, 1097479840],
[1.4375, 9.34375, 1097479840],
]


def perturb_walls(w, idx, amount=0.1):
# Add small random offset to one wall endpoint
w[idx][1] = w[idx][1] + amount
return w


def get_robot(p_noise):
return RobotCapabilities(
p_noise=jnp.array(p_noise),
hd_noise=jnp.array(0.03),
sensor_noise=jnp.array(0.1),
n_sensors=jnp.array(8),
sensor_range=jnp.array(10.0),
)


# Test 2: Perturb robot capabilities


# Create random keys
keys = jax.random.split(PRNGKey(0), 100)

# Test 1: Run simulation with perturbed walls
print("Test 1: Perturbing walls")
start = time.time()
all_paths_1, all_readings_1 = jax.vmap(
lambda k: simulate_robot(
World(*walls_to_jax(walls)),
get_robot(0.1),
jnp.array(robot_path),
k,
)
)(keys)
print(f"Wall perturbation test took {time.time() - start:.3f} seconds")

# Test 2: Run simulation with perturbed robot capabilities
print("\nTest 2: Perturbing robot capabilities")
start = time.time()
p_noises = jnp.linspace(0.05, 0.15, 100) # Range of p_noise values
all_paths_2, all_readings_2 = jax.vmap(
lambda k, p: simulate_robot(
World(*walls_to_jax(walls)), get_robot(p), jnp.array(robot_path), k
)
)(keys, p_noises)
print(f"Robot capability perturbation test took {time.time() - start:.3f} seconds")
6 changes: 6 additions & 0 deletions robot_2/emoji.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# either Cursor or Claude has a bug where strings containing emoji break responses.
# so I keep them in a separate file.
robot = "🤖"
pencil = "✏️"
recycle = "♻️"
clipboard = "📋"
Loading