Skip to content
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

Simulate robot battery usage and charging #235

Merged
merged 8 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
14 changes: 9 additions & 5 deletions docs/source/usage/robot_actions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ Simulating Action Execution
By default, all robots can execute their actions perfectly.
However, actions can still fail due to planning errors or because they are infeasible (e.g, picking an object while holding another).

You can use the action's *execution options* to modify the behavior of your robot to simulate delays or failures.
You can use the action's *execution options* to modify the behavior of your robot to simulate delays, failures, or battery consumption.
For example,

.. code-block:: python
Expand All @@ -104,14 +104,18 @@ For example,

robot = Robot(
name="robot0",
initial_battery_level=100.0,
action_execution_options = {
"navigate": ExecutionOptions(
delay=0.1,
success_probability=0.5,
rng_seed=1234
rng_seed=1234,
battery_usage=1.0,
),
"pick": ExecutionOptions(
delay=1.0,
success_probability=0.75,
battery_usage=5.0
),
"pick": ExecutionOptions(delay=1.0),
"place": ExecutionOptions(success_probability=0.75),
},
)

Expand Down
1 change: 1 addition & 0 deletions docs/source/yaml/location_schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ The generic location schema, where ``<angle brackets>`` are placeholders, is:
color: [<r>, <g>, <b>]
is_open: True
is_locked: False
is_charger: False


Examples
Expand Down
9 changes: 7 additions & 2 deletions docs/source/yaml/world_schema.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ The world schema looks as follows, where ``<angle brackets>`` are placeholders:
height: <value> # Robot height
location: <loc_name> # Initial location
pose: [<x>, <y>, <z>, <yaw>] # Initial pose, if not specified will sample
initial_battery_level: 50.0
# Dynamics limits
max_linear_velocity: <value>
max_angular_velocity: <value>
Expand All @@ -44,12 +45,15 @@ The world schema looks as follows, where ``<angle brackets>`` are placeholders:
action_execution_options:
navigate:
delay: 0.1
success_probability: 0.5
rng_seed: 1234
success_probability: 0.9
rng_seed: 42
battery_usage: 1.0
pick:
delay: 1.0
battery_usage: 5.0
place:
success_probability: 0.75
battery_usage: 5.0
- ...
- ...

Expand Down Expand Up @@ -88,6 +92,7 @@ The world schema looks as follows, where ``<angle brackets>`` are placeholders:
pose: [<x>, <y>, <z>, <yaw>] # If not specified, will sample
is_open: true # Can only pick, place, and detect if open
is_locked: true # Can only open and close if unlocked
is_charger: false # Robots can charge at this location
- ...
- ...

Expand Down
4 changes: 4 additions & 0 deletions pyrobosim/pyrobosim/core/locations.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def __init__(
color=None,
is_open=True,
is_locked=False,
is_charger=False,
):
"""
Creates a location instance.
Expand All @@ -60,6 +61,8 @@ def __init__(
:type is_open: bool, optional
:param is_locked: If True, the location is locked, meaning it cannot be opened or closed.
:type is_locked: bool, optional
:param is_charger: If True, the robot charges its battery at this location.
:type is_charger: bool, optional
"""
# Validate input
if parent is None:
Expand All @@ -73,6 +76,7 @@ def __init__(
self.parent = parent
self.is_open = is_open
self.is_locked = is_locked
self.is_charger = is_charger

self.metadata = Location.metadata.get(self.category)
if not self.metadata:
Expand Down
Loading
Loading