Skip to content

Commit

Permalink
Update SDK
Browse files Browse the repository at this point in the history
  • Loading branch information
glannuzel committed Apr 17, 2024
1 parent 59e497e commit dcdd4c4
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 308 deletions.
42 changes: 12 additions & 30 deletions config/_default/menus/menus.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -271,44 +271,26 @@
parent = "sdk-first-moves"
url = "/sdk/first-moves/record"

[[sdk]]
name = "8. Use the mobile base"
weight = 370
parent = "sdk-first-moves"
url = "/sdk/first-moves/mobile-base"

##################
## Mobile base section
## Advanced section
##################

[[sdk]]
name = "Mobile base"
name = "Advanced"
weight = 40
identifier = "sdk-mobile-base"
identifier = "sdk-advanced"

[[sdk]]
name = "Getting started with the mobile base"
name = "Mobile base modes"
weight = 400
parent = "sdk-mobile-base"
url = "/sdk/mobile-base/getting-started"

[[sdk]]
name = "Moving the mobile base"
weight = 410
parent = "sdk-mobile-base"
url = "/sdk/mobile-base/moving-the-base"

[[sdk]]
name = "Advanced"
weight = 420
parent = "sdk-mobile-base"
url = "/sdk/mobile-base/drive-control-modes"

[[sdk]]
name = "Anti-collision safety"
weight = 430
parent = "sdk-mobile-base"
url = "/sdk/mobile-base/safety"

[[sdk]]
name = "Using the mobile base without Reachy"
weight = 440
parent = "sdk-mobile-base"
url = "/sdk/mobile-base/mobile-base-alone"
parent = "sdk-advanced"
url = "/sdk/advanced/mobile-base"

#############################################
# Menu main - add parts to main page nav menu here!
Expand Down
2 changes: 1 addition & 1 deletion content/advanced/safety/mobile-base.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ We recommend that you get a feel for the inertia of the robot by holding on to t
Block a wheel with your foot and try to gently tilt the robot.


Then use the controller to move around the robot as explained in [Moving the mobile base]({{< ref "sdk/mobile-base/moving-the-base" >}})
Then use the controller to move around the robot as explained in [Moving the mobile base]({{< ref "sdk/first-moves/mobile-base" >}})

{{< video "videos/advanced/mobile-base/controller_mouvement.mp4" "100%" >}}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
---
title : "Developing with Python SDK"
description: "Use Reachy 2 Python SDK."
lead: ""
date: 2023-07-25T17:37:16+02:00
lastmod: 2023-07-25T17:37:16+02:00
draft: false
images: []
type: docs
---
---
title : "Advanced Python SDK features"
description: "Use Reachy 2 Python SDK, advanced features."
lead: ""
date: 2023-07-25T17:37:16+02:00
lastmod: 2023-07-25T17:37:16+02:00
draft: false
images: []
type: docs
---
Original file line number Diff line number Diff line change
@@ -1,70 +1,70 @@
---
title: "Advanced"
description: "Drive modes and control modes description for the mobile base."
date: 2023-07-26T08:32:17+02:00
lastmod: 2023-07-26T08:32:17+02:00
draft: false
images: []
type: docs
toc: true
weight: "160"
---
## Drive modes
### Overview
The drive mode impacts the way the mobile base accepts commands. We could say it's the current state of the mobile base.

In most cases, there is no need to think about these modes or to handle them in your code. Below are the most common use cases.
* If you want to use the set_speed method to spam speed commands (e.g. pilot the robot with a controller), the mode has to be manually changed to 'cmd_vel':
```python
reachy_mobile.mobile_base.drive_mode = 'cmd_vel'
```
* If you want to push the robot easily, this will set the wheels in a compliancy state:
```python
reachy_mobile.mobile_base.drive_mode = 'free_wheel'
```
* On the contrary, if you want the robot to apply a passive resistance to movement, use:
```python
reachy_mobile.mobile_base.drive_mode = 'brake'
```

You can use this [Jupyter Notebook](https://github.com/pollen-robotics/mobile-base-sdk/blob/main/mobile_base_sdk/examples/notebooks/drive-modes.ipynb) to explore the drive modes with your mobile base.

### Detailed behaviour
This section is only useful if you intend to interact directly with the Hardware Abstraction Layer (HAL).

Six drive modes are available for the mobile base:
* **cmd_vel**: in this mode, speed instructions can be spammed to the wheels controllers. This mode is used for the *set_speed* method.
* **brake**: in this mode, the wheels will be stiff.
* **free_wheel**: in this mode, the wheels will be as compliant as possible.
* **emergency_stop**: in this mode, the wheels will stop receiving mobility commands. Switching to this mode will also stop the mobile base hal code. This is a safety mode.
* **speed**: another mode to send speed instructions, but less frequently than with the cmd_vel mode. This mode is actually not used at this level (python SDK level), but is implemented at the ROS level, in case one might need it.
* **goto**: this mode is used for the *goto* method.

*note: the 'speed' and 'goto' modes can't be changed by hand. The drive mode is handled automagically when requesting a set_speed or a goto.*

The code for the [HAL can be found here](https://github.com/pollen-robotics/zuuu_hal)

## Control modes
### Overview
The control mode dictates the low level control strategy used by the mobile bases's HAL.

Two control modes are possible:
* ***open_loop*** (default mode): in this mode, the wheels are compliant and the control is smoother.
```python
reachy_mobile.mobile_base.control_mode = 'open_loop'
```

* ***pid***: in this mode, the wheels are stiff and the control is more precise.
```python
reachy_mobile.mobile_base.control_mode = 'pid'
```
:bulb: We recommend that you run the following [Jupyter Notebook](https://github.com/pollen-robotics/mobile-base-sdk/blob/main/mobile_base_sdk/examples/notebooks/control-modes.ipynb) to get a feel of what the control mode does.

### Detailed behaviour
Regardless of how the mobile base is piloted (goto, set_speed, controller), the HAL always ends up calculating a goal rotational speed for each wheel.
The control mode only changes the used strategy to reach that rotational speed.
* In the open_loop mode, a simple affine model was identified to match a PWM to a goal rotational speed. The VESC controllers then apply the PWM directly to the motors of the wheels, without any other low level control. The measures can be found [here](https://github.com/pollen-robotics/zuuu_hal/tree/main/measures). While the model is simple, it does account for the static friction and the experimental data shows a good fit when the mobile base is on a flat surface.

{{< img-center "images/sdk/mobile-base/affine_pwm_model.png" 400x "" >}}

---
title: "Mobile base drive and control modes"
description: "Drive modes and control modes description for the mobile base."
date: 2023-07-26T08:32:17+02:00
lastmod: 2023-07-26T08:32:17+02:00
draft: false
images: []
type: docs
toc: true
weight: "160"
---
## Drive modes
### Overview
The drive mode impacts the way the mobile base accepts commands. We could say it's the current state of the mobile base.

In most cases, there is no need to think about these modes or to handle them in your code. Below are the most common use cases.
* If you want to use the set_speed method to spam speed commands (e.g. pilot the robot with a controller), the mode has to be manually changed to 'cmd_vel':
```python
reachy_mobile.mobile_base.drive_mode = 'cmd_vel'
```
* If you want to push the robot easily, this will set the wheels in a compliancy state:
```python
reachy_mobile.mobile_base.drive_mode = 'free_wheel'
```
* On the contrary, if you want the robot to apply a passive resistance to movement, use:
```python
reachy_mobile.mobile_base.drive_mode = 'brake'
```

You can use this [Jupyter Notebook](https://github.com/pollen-robotics/mobile-base-sdk/blob/main/mobile_base_sdk/examples/notebooks/drive-modes.ipynb) to explore the drive modes with your mobile base.

### Detailed behaviour
This section is only useful if you intend to interact directly with the Hardware Abstraction Layer (HAL).

Six drive modes are available for the mobile base:
* **cmd_vel**: in this mode, speed instructions can be spammed to the wheels controllers. This mode is used for the *set_speed* method.
* **brake**: in this mode, the wheels will be stiff.
* **free_wheel**: in this mode, the wheels will be as compliant as possible.
* **emergency_stop**: in this mode, the wheels will stop receiving mobility commands. Switching to this mode will also stop the mobile base hal code. This is a safety mode.
* **speed**: another mode to send speed instructions, but less frequently than with the cmd_vel mode. This mode is actually not used at this level (python SDK level), but is implemented at the ROS level, in case one might need it.
* **goto**: this mode is used for the *goto* method.

*note: the 'speed' and 'goto' modes can't be changed by hand. The drive mode is handled automagically when requesting a set_speed or a goto.*

The code for the [HAL can be found here](https://github.com/pollen-robotics/zuuu_hal)

## Control modes
### Overview
The control mode dictates the low level control strategy used by the mobile bases's HAL.

Two control modes are possible:
* ***open_loop*** (default mode): in this mode, the wheels are compliant and the control is smoother.
```python
reachy_mobile.mobile_base.control_mode = 'open_loop'
```

* ***pid***: in this mode, the wheels are stiff and the control is more precise.
```python
reachy_mobile.mobile_base.control_mode = 'pid'
```
:bulb: We recommend that you run the following [Jupyter Notebook](https://github.com/pollen-robotics/mobile-base-sdk/blob/main/mobile_base_sdk/examples/notebooks/control-modes.ipynb) to get a feel of what the control mode does.

### Detailed behaviour
Regardless of how the mobile base is piloted (goto, set_speed, controller), the HAL always ends up calculating a goal rotational speed for each wheel.
The control mode only changes the used strategy to reach that rotational speed.
* In the open_loop mode, a simple affine model was identified to match a PWM to a goal rotational speed. The VESC controllers then apply the PWM directly to the motors of the wheels, without any other low level control. The measures can be found [here](https://github.com/pollen-robotics/zuuu_hal/tree/main/measures). While the model is simple, it does account for the static friction and the experimental data shows a good fit when the mobile base is on a flat surface.

{{< img-center "images/sdk/mobile-base/affine_pwm_model.png" 400x "" >}}

* In the pid mode, the HAL gives the goal rotational speeds directly to the VESC controllers of each wheel. The VESC will use a PID controller to control the speeds.
Loading

0 comments on commit dcdd4c4

Please sign in to comment.