Commit f182bffc authored by Pierre Fernbach's avatar Pierre Fernbach
Browse files

[Demo] WIP add a notebook folder

parent d30b64c7
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"## Main classes\n",
"\n",
"This package define 4 main classes representing physical concepts of legged locomotion. Contact Model, Contact Patch, Contact Phase and Contact Sequence.\n",
"\n",
"A Contact Model define the physical properties of a contact. A Contact Patch define completely a contact between a part of the robot and the environment, it contain a Contact Model. A Contact Phase is defined by a constant set of contacts, it contains one or more Contact Patches. Finally, a Contact Sequence is a sequence of Contact Phases.\n",
"\n",
"### Contact Model\n",
"\n",
"\n",
"A Contact Model define the physical properties of a contact: the type of contact (Planar or Point), the physical positions of the contact points with respect to the \"center\" of the contact, and the coefficient of friction for this contact. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Contact Type: CONTACT_UNDEFINED\n",
"Friction coefficient: -1.0\n"
]
}
],
"source": [
"import numpy as np\n",
"from multicontact_api import ContactType, ContactModel\n",
"\n",
"cm_default = ContactModel()\n",
"print(\"Contact Type: \", cm_default.contact_type)\n",
"print(\"Friction coefficient: \", cm_default.mu)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The default constructor create a ContactModel with \"undefined\" values. Other constructors exist to build a ContactModel with a friction coefficient or a contact type:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cm1 friction coefficient: 0.5\n",
"cm2 Contact Type: CONTACT_POINT\n",
"cm2 friction coefficient: 0.9\n",
"cm2 number of contact points: 1\n",
"cm2 contact point position: [0. 0. 0.]\n"
]
}
],
"source": [
"cm1 = ContactModel(0.5)\n",
"print(\"cm1 friction coefficient:\", cm1.mu)\n",
"\n",
"cm2 = ContactModel(0.9, ContactType.CONTACT_POINT)\n",
"print(\"cm2 Contact Type: \", cm2.contact_type)\n",
"print(\"cm2 friction coefficient:\", cm2.mu)\n",
"print(\"cm2 number of contact points: \", cm2.num_contact_points)\n",
"print(\"cm2 contact point position: \", cm2.contact_points_positions)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The contact point position are expressed in the contact frame (see the next section for more details). By default they are positionned at the origin. It is also possible to create contact model for planar contacts, and define the contacts positions at the corners of a rectangular feet:"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cm_planar number of contact points: 1\n"
]
}
],
"source": [
"cm_planar = ContactModel(0.5, ContactType.CONTACT_PLANAR)\n",
"# define 4 contacts points at the corners of a rectangle:\n",
"cm_planar.num_contact_points = 4\n",
"\n",
"lx = 0.2 / 2. # half size of the feet along x axis\n",
"ly = 0.13 / 2. # half size of the feet along y axis\n",
"\n",
"cm_planar.contact_points_positions[0, :] = [-lx, -lx, lx, lx]\n",
"cm_planar.contact_points_positions[1, :] = [-ly, ly, -ly, ly]\n",
"cm_planar.contact_points_positions[2, :] = [0] * 4\n",
"\n",
"\n"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% Cell type:markdown id: tags:
## Main classes
This package define 4 main classes representing physical concepts of legged locomotion. Contact Model, Contact Patch, Contact Phase and Contact Sequence.
A Contact Model define the physical properties of a contact. A Contact Patch define completely a contact between a part of the robot and the environment, it contain a Contact Model. A Contact Phase is defined by a constant set of contacts, it contains one or more Contact Patches. Finally, a Contact Sequence is a sequence of Contact Phases.
### Contact Model
A Contact Model define the physical properties of a contact: the type of contact (Planar or Point), the physical positions of the contact points with respect to the "center" of the contact, and the coefficient of friction for this contact.
%% Cell type:code id: tags:
``` python
import numpy as np
from multicontact_api import ContactType, ContactModel
cm_default = ContactModel()
print("Contact Type: ", cm_default.contact_type)
print("Friction coefficient: ", cm_default.mu)
```
%%%% Output: stream
Contact Type: CONTACT_UNDEFINED
Friction coefficient: -1.0
%% Cell type:markdown id: tags:
The default constructor create a ContactModel with "undefined" values. Other constructors exist to build a ContactModel with a friction coefficient or a contact type:
%% Cell type:code id: tags:
``` python
cm1 = ContactModel(0.5)
print("cm1 friction coefficient:", cm1.mu)
cm2 = ContactModel(0.9, ContactType.CONTACT_POINT)
print("cm2 Contact Type: ", cm2.contact_type)
print("cm2 friction coefficient:", cm2.mu)
print("cm2 number of contact points: ", cm2.num_contact_points)
print("cm2 contact point position: ", cm2.contact_points_positions)
```
%%%% Output: stream
cm1 friction coefficient: 0.5
cm2 Contact Type: CONTACT_POINT
cm2 friction coefficient: 0.9
cm2 number of contact points: 1
cm2 contact point position: [0. 0. 0.]
%% Cell type:markdown id: tags:
The contact point position are expressed in the contact frame (see the next section for more details). By default they are positionned at the origin. It is also possible to create contact model for planar contacts, and define the contacts positions at the corners of a rectangular feet:
%% Cell type:code id: tags:
``` python
cm_planar = ContactModel(0.5, ContactType.CONTACT_PLANAR)
# define 4 contacts points at the corners of a rectangle:
cm_planar.num_contact_points = 4
lx = 0.2 / 2. # half size of the feet along x axis
ly = 0.13 / 2. # half size of the feet along y axis
cm_planar.contact_points_positions[0, :] = [-lx, -lx, lx, lx]
cm_planar.contact_points_positions[1, :] = [-ly, ly, -ly, ly]
cm_planar.contact_points_positions[2, :] = [0] * 4
```
%%%% Output: stream
cm_planar number of contact points: 1
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 4
}
{
"cells": [],
"metadata": {},
"nbformat": 4,
"nbformat_minor": 4
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n",
"## Main classes\n",
"\n",
"This package define 4 main classes representing physical concepts of legged locomotion. Contact Model, Contact Patch, Contact Phase and Contact Sequence.\n",
"\n",
"A Contact Model define the physical properties of a contact. A Contact Patch define completely a contact between a part of the robot and the environment, it contain a Contact Model. A Contact Phase is defined by a constant set of contacts, it contains one or more Contact Patches. Finally, a Contact Sequence is a sequence of Contact Phases.\n",
"\n",
"### Contact Model\n",
"\n",
"\n",
"A Contact Model define the physical properties of a contact: the type of contact (Planar or Point), the physical positions of the contact points with respect to the \"center\" of the contact, and the coefficient of friction for this contact. "
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Contact Type: CONTACT_UNDEFINED\n",
"Friction coefficient: -1.0\n"
]
}
],
"source": [
"import numpy as np\n",
"from multicontact_api import ContactType, ContactModel\n",
"\n",
"cm_default = ContactModel()\n",
"print(\"Contact Type: \", cm_default.contact_type)\n",
"print(\"Friction coefficient: \", cm_default.mu)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The default constructor create a ContactModel with \"undefined\" values. Other constructors exist to build a ContactModel with a friction coefficient or a contact type:"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cm1 friction coefficient: 0.5\n",
"cm2 Contact Type: CONTACT_POINT\n",
"cm2 friction coefficient: 0.9\n",
"cm2 number of contact points: 1\n",
"cm2 contact point position: [0. 0. 0.]\n"
]
}
],
"source": [
"cm1 = ContactModel(0.5)\n",
"print(\"cm1 friction coefficient:\", cm1.mu)\n",
"\n",
"cm2 = ContactModel(0.9, ContactType.CONTACT_POINT)\n",
"print(\"cm2 Contact Type: \", cm2.contact_type)\n",
"print(\"cm2 friction coefficient:\", cm2.mu)\n",
"print(\"cm2 number of contact points: \", cm2.num_contact_points)\n",
"print(\"cm2 contact point position: \", cm2.contact_points_positions)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"The contact point position are expressed in the contact frame (see the next section for more details). By default they are positionned at the origin. It is also possible to create contact model for planar contacts and define the contacts positions at the corners of a rectangular feet:"
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cm_planar: ContactType: 1, mu: 0.5\n",
"Number of contact points: 4, positions: \n",
" -0.1 -0.1 0.1 0.1\n",
"-0.065 0.065 -0.065 0.065\n",
" 0 0 0 0\n",
"\n"
]
}
],
"source": [
"cm_planar = ContactModel(0.5, ContactType.CONTACT_PLANAR)\n",
"# define 4 contacts points at the corners of a rectangle:\n",
"cm_planar.num_contact_points = 4\n",
"\n",
"lx = 0.2 / 2. # half size of the feet along x axis\n",
"ly = 0.13 / 2. # half size of the feet along y axis\n",
"\n",
"contact_points = np.zeros([3,4])\n",
"contact_points[0, :] = [-lx, -lx, lx, lx]\n",
"contact_points[1, :] = [-ly, ly, -ly, ly]\n",
"\n",
"cm_planar.contact_points_positions = contact_points\n",
"# print the contact model data:\n",
"\n",
"print(\"cm_planar: \", cm_planar)\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### Contact Patch\n",
"\n",
"A contact patch define the placement (in SE(3), in the world frame) of a contact between a part of the robot and the environment. It contains a ContactModel."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% Cell type:markdown id: tags:
## Main classes
This package define 4 main classes representing physical concepts of legged locomotion. Contact Model, Contact Patch, Contact Phase and Contact Sequence.
A Contact Model define the physical properties of a contact. A Contact Patch define completely a contact between a part of the robot and the environment, it contain a Contact Model. A Contact Phase is defined by a constant set of contacts, it contains one or more Contact Patches. Finally, a Contact Sequence is a sequence of Contact Phases.
### Contact Model
A Contact Model define the physical properties of a contact: the type of contact (Planar or Point), the physical positions of the contact points with respect to the "center" of the contact, and the coefficient of friction for this contact.
%% Cell type:code id: tags:
``` python
import numpy as np
from multicontact_api import ContactType, ContactModel
cm_default = ContactModel()
print("Contact Type: ", cm_default.contact_type)
print("Friction coefficient: ", cm_default.mu)
```
%%%% Output: stream
Contact Type: CONTACT_UNDEFINED
Friction coefficient: -1.0
%% Cell type:markdown id: tags:
The default constructor create a ContactModel with "undefined" values. Other constructors exist to build a ContactModel with a friction coefficient or a contact type:
%% Cell type:code id: tags:
``` python
cm1 = ContactModel(0.5)
print("cm1 friction coefficient:", cm1.mu)
cm2 = ContactModel(0.9, ContactType.CONTACT_POINT)
print("cm2 Contact Type: ", cm2.contact_type)
print("cm2 friction coefficient:", cm2.mu)
print("cm2 number of contact points: ", cm2.num_contact_points)
print("cm2 contact point position: ", cm2.contact_points_positions)
```
%%%% Output: stream
cm1 friction coefficient: 0.5
cm2 Contact Type: CONTACT_POINT
cm2 friction coefficient: 0.9
cm2 number of contact points: 1
cm2 contact point position: [0. 0. 0.]
%% Cell type:markdown id: tags:
The contact point position are expressed in the contact frame (see the next section for more details). By default they are positionned at the origin. It is also possible to create contact model for planar contacts and define the contacts positions at the corners of a rectangular feet:
%% Cell type:code id: tags:
``` python
cm_planar = ContactModel(0.5, ContactType.CONTACT_PLANAR)
# define 4 contacts points at the corners of a rectangle:
cm_planar.num_contact_points = 4
lx = 0.2 / 2. # half size of the feet along x axis
ly = 0.13 / 2. # half size of the feet along y axis
contact_points = np.zeros([3,4])
contact_points[0, :] = [-lx, -lx, lx, lx]
contact_points[1, :] = [-ly, ly, -ly, ly]
cm_planar.contact_points_positions = contact_points
# print the contact model data:
print("cm_planar: ", cm_planar)
```
%%%% Output: stream
cm_planar: ContactType: 1, mu: 0.5
Number of contact points: 4, positions:
-0.1 -0.1 0.1 0.1
-0.065 0.065 -0.065 0.065
0 0 0 0
%% Cell type:markdown id: tags:
### Contact Patch
A contact patch define the placement (in SE(3), in the world frame) of a contact between a part of the robot and the environment. It contains a ContactModel.
%% Cell type:code id: tags:
``` python
```
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% Cell type:code id: tags:
``` python
```
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.2"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
%% Cell type:code id: tags:
``` python
```
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment