{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"colab_type": "text",
"id": "view-in-github",
"tags": [
"no-tex"
]
},
"source": [
""
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "_lb_cdVxGrN1",
"outputId": "8e5f4d6e-a5ba-4011-9fa9-a9ef3627686b",
"tags": [
"remove-cell"
]
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Note: you may need to restart the kernel to use updated packages.\n"
]
}
],
"source": [
"%pip install -U -q gtbook\n"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"id": "_vgA01LrHBkU",
"tags": [
"remove-cell"
]
},
"outputs": [],
"source": [
"import gtsam\n",
"\n",
"import gtbook\n",
"import gtbook.display\n",
"from gtbook import vacuum\n",
"from gtbook.discrete import Variables\n",
"\n",
"VARIABLES = Variables()\n",
"def pretty(obj):\n",
" return gtbook.display.pretty(obj, VARIABLES)\n",
"def show(obj, **kwargs):\n",
" return gtbook.display.show(obj, VARIABLES, **kwargs)\n",
"\n",
"# From section 3.1:\n",
"X = VARIABLES.discrete_series(\"X\", [1], vacuum.rooms)\n",
"state_prior = gtsam.DiscreteDistribution(X[1], \"0/0/1/0/0\")\n"
]
},
{
"attachments": {},
"cell_type": "markdown",
"metadata": {
"id": "dd_NRh1QLVrg"
},
"source": [
"# Actions over time\n",
"\n",
"> Using the language of probability to describe systems with uncertainty in the effects of actions.\n",
"\n",
"
"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In the real world, robots do not always execute actions perfectly, for a\n",
"variety of reasons. \n",
"To model the uncertainty when executing an action, we will once again use the\n",
"language of probability. \n",
"We will use *conditional probability distributions* to model how we can affect the state \n",
"of the robot by actions. \n",
"Recall that in Chapter 2 we used conditional probabilities to model\n",
"the effects of uncertainty in sensing at a specific moment in time.\n",
"Here, we use conditional probabilities to model the uncertainty in state transitions when\n",
"actions are executed.\n",
"\n",
"We can model this using graphs, with directed edges that specify conditional\n",
"probabilities on variables.\n",
"We can use these \"graphical models\" to generate sample system trajectories\n",
"for a fixed sequence of actions.\n",
"Such sample trajectories can be used for planning, as we will see later in the chapter.\n",
"In addition, the graphical model approach allows us to easily extend probabilistic actions to\n",
"factored state representations, which can provide significant computational advantages."
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"In our example, we assume that our robot is equipped with navigation software that implements four\n",
"primitive actions: *move left, move right, move up, move down*,\n",
"which we will denote by *L,R,U,D*.\n",
"Together, these four actions define the **action space**.\n",
"The nominal effects of these actions (i.e., the effects of the actions without taking into account uncertainty) \n",
"are to move the robot from the current room to an adjacent\n",
"room, according to the direction specified by the action.\n",
"For example, executing the *move down* action from the living room should take the robot into the hallway.\n",
"\n",
"\n",
"
\n",
"
\n",
"
\n",
"
P(X2|X1,A1):
\n", "X1 | A1 | Living Room | Kitchen | Office | Hallway | Dining Room |
---|---|---|---|---|---|---|
Living Room | L | 1 | 0 | 0 | 0 | 0 |
Living Room | R | 0.2 | 0.8 | 0 | 0 | 0 |
Living Room | U | 1 | 0 | 0 | 0 | 0 |
Living Room | D | 0.2 | 0 | 0 | 0.8 | 0 |
Kitchen | L | 0.8 | 0.2 | 0 | 0 | 0 |
Kitchen | R | 0 | 1 | 0 | 0 | 0 |
Kitchen | U | 0 | 1 | 0 | 0 | 0 |
Kitchen | D | 0 | 0.2 | 0 | 0 | 0.8 |
Office | L | 0 | 0 | 1 | 0 | 0 |
Office | R | 0 | 0 | 0.2 | 0.8 | 0 |
Office | U | 0 | 0 | 1 | 0 | 0 |
Office | D | 0 | 0 | 1 | 0 | 0 |
Hallway | L | 0 | 0 | 0.8 | 0.2 | 0 |
Hallway | R | 0 | 0 | 0 | 0.2 | 0.8 |
Hallway | U | 0.8 | 0 | 0 | 0.2 | 0 |
Hallway | D | 0 | 0 | 0 | 1 | 0 |
Dining Room | L | 0 | 0 | 0 | 0.8 | 0.2 |
Dining Room | R | 0 | 0 | 0 | 0 | 1 |
Dining Room | U | 0 | 0.8 | 0 | 0 | 0.2 |
Dining Room | D | 0 | 0 | 0 | 0 | 1 |
P(X2):
\n", "X2 | value |
---|---|
Living Room | 0 |
Kitchen | 0 |
Office | 0.2 |
Hallway | 0.8 |
Dining Room | 0 |
P(B2|B1):
\n", "B1 | full | half | empty |
---|---|---|---|
full | 0.9 | 0.1 | 0 |
half | 0 | 0.9 | 0.1 |
empty | 0 | 0 | 1 |
P(X2|X1,A1):
\n", "X1 | A1 | Living Room | Kitchen | Office | Hallway | Dining Room |
---|---|---|---|---|---|---|
Living Room | L | 1 | 0 | 0 | 0 | 0 |
Living Room | R | 0.2 | 0.8 | 0 | 0 | 0 |
Living Room | U | 1 | 0 | 0 | 0 | 0 |
Living Room | D | 0.2 | 0 | 0 | 0.8 | 0 |
Kitchen | L | 0.8 | 0.2 | 0 | 0 | 0 |
Kitchen | R | 0 | 1 | 0 | 0 | 0 |
Kitchen | U | 0 | 1 | 0 | 0 | 0 |
Kitchen | D | 0 | 0.2 | 0 | 0 | 0.8 |
Office | L | 0 | 0 | 1 | 0 | 0 |
Office | R | 0 | 0 | 0.2 | 0.8 | 0 |
Office | U | 0 | 0 | 1 | 0 | 0 |
Office | D | 0 | 0 | 1 | 0 | 0 |
Hallway | L | 0 | 0 | 0.8 | 0.2 | 0 |
Hallway | R | 0 | 0 | 0 | 0.2 | 0.8 |
Hallway | U | 0.8 | 0 | 0 | 0.2 | 0 |
Hallway | D | 0 | 0 | 0 | 1 | 0 |
Dining Room | L | 0 | 0 | 0 | 0.8 | 0.2 |
Dining Room | R | 0 | 0 | 0 | 0 | 1 |
Dining Room | U | 0 | 0.8 | 0 | 0 | 0.2 |
Dining Room | D | 0 | 0 | 0 | 0 | 1 |
P(B2|A2,B1):
\n", "A2 | B1 | full | half | empty |
---|---|---|---|---|
L | full | 0.9 | 0.1 | 0 |
L | half | 0 | 0.9 | 0.1 |
L | empty | 0 | 0 | 1 |
R | full | 0.9 | 0.1 | 0 |
R | half | 0 | 0.9 | 0.1 |
R | empty | 0 | 0 | 1 |
U | full | 0.9 | 0.1 | 0 |
U | half | 0 | 0.9 | 0.1 |
U | empty | 0 | 0 | 1 |
D | full | 0.9 | 0.1 | 0 |
D | half | 0 | 0.9 | 0.1 |
D | empty | 0 | 0 | 1 |