-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from iwishiwasaneagle/libjdrones
feat: Adapt jdrones to be mainly run via libjdrones C++
- Loading branch information
Showing
19 changed files
with
306 additions
and
701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
gymnasium==0.29.1 | ||
libjdrones==0.1.1 | ||
loguru==0.7.0 | ||
matplotlib==3.8.3 | ||
nptyping==2.5.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,7 @@ | ||
# Copyright 2023 Jan-Hendrik Ewers | ||
# SPDX-License-Identifier: GPL-3.0-only | ||
import abc | ||
from typing import Dict | ||
from typing import Optional | ||
from typing import Tuple | ||
|
||
import gymnasium | ||
from jdrones.controllers import Controller | ||
from jdrones.controllers import PID | ||
from jdrones.data_models import State | ||
from jdrones.envs.base.basedronenev import BaseDroneEnv | ||
|
||
|
||
class BaseControlledEnv(gymnasium.Env, abc.ABC): | ||
env: BaseDroneEnv | ||
|
||
controllers: Dict[str, PID] | ||
|
||
def __init__(self, env: BaseDroneEnv, dt: float = 1 / 240): | ||
self.env = env | ||
self.dt = dt | ||
self.controllers = self._init_controllers() | ||
|
||
self.observation_space = self.env.observation_space | ||
|
||
@property | ||
def state(self): | ||
return self.env.state | ||
|
||
@property | ||
def initial_state(self): | ||
return self.env.initial_state | ||
|
||
def reset( | ||
self, | ||
*, | ||
seed: Optional[int] = None, | ||
options: Optional[dict] = None, | ||
) -> Tuple[State, dict]: | ||
super().reset(seed=seed, options=options) | ||
for ctrl in self.controllers.values(): | ||
ctrl.reset() | ||
return self.env.reset(options=options) | ||
|
||
@abc.abstractmethod | ||
def _init_controllers(self) -> dict[str, Controller]: | ||
pass | ||
class BaseControlledEnv(gymnasium.Env): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.