btx0424 / OmniDrones

https://omnidrones.readthedocs.io/
MIT License
126 stars 23 forks source link

[Refactor] Better controller interface. #33

Open btx0424 opened 9 months ago

btx0424 commented 9 months ago

The current implementation of controllers as Transform, though a good abstraction on top of MDPs, can be somehow inflexible in many cases. We would like to

  1. Make controllers as choices of action spaces.
  2. Manage controllers and parameters for different drone models through a registry/factory.

It would be something like:

from omni_drones.control import Controller

class MultirotorBase(RobotBase):
  def __init__(.self, cfg):
    ...
    self.controller = Controller.make(self, cfg)
    self.action_spec = ... # define action_spec accordingly

  def apply_action(self, actions):
    actions = self.controller(self.state, actions)
    ...

This way, we will be able to use substeps:


class SomeEnv(IsaacEnv):
  ...
  def _step(self, tensordict: TensorDictBase):
    actions = tensordict[("agents", "action")]
    for substep in range(self.substeps):
      self.drone.apply_action(actions)
      self.sim.step(...)
    ...