GithubHelp home page GithubHelp logo

Comments (10)

JacopoPan avatar JacopoPan commented on July 18, 2024 2

@yuchen-x yes, the whole point is that creating those extra environments is computationally wasteful.
The solution is simply, as you say, to re-implement the __init__() methods to take the appropriate parameters (it's 4 in the base class but a few more in the non-abstract subclasses) instead of reading them from an environment.
This week has been a bit busy so far but that's the same fix I intend to push by the end of it.

from gym-pybullet-drones.

yuchen-x avatar yuchen-x commented on July 18, 2024 1

Hi,

I noticed that you had also integrated controllers in BaeMultiagentAviary.py at line 80-83.

If I understand correctly, for example, line 81 will load two (num_drones=2) drones connecting the Pybullet engine,

80: if drone_model in [DroneModel.CF2X, DroneModel.CF2P]:
81: self.ctrl = [DSLPIDControl(CtrlAviary(drone_model=DroneModel.CF2X)) for i in range(num_drones)]

And, then after the super()init call at line 84, there will be another two drones loaded. Thus, there are three pybullet environments being created and four drones loaded in the end, correct?

I noticed the BaseControl class required only 4 arguments from the env:

DRONE_MODEL
GRAVITY
KF
KM

Then, I guess I can modify DSLPIDControl and BaseControl class to receive the above four arguments rather than an env, and then create controllers inside of BaseAviary Class according to the number of drones, right? I am not sure if this is gonna lead to any potential issue, so I'd like to double-check with you.

Thanks!

from gym-pybullet-drones.

JacopoPan avatar JacopoPan commented on July 18, 2024

Hi @Cakhavan, thanks for pointing this out/reminding me. The error you encountered is relatively minor (I used the attribute before setting it in the superclass constructor instead of the parameter) but there is still a more structural problem in using PID control within the RL classes which I haven't fixed yet: I originally made controllers as classes taking their environment as a parameter; now, embedding one into the other, creates all sorts of circular dependencies (and that's bad).

I'm aware of it but didn't have time to re-structure the code just yet, hopefully by the end of the upcoming week πŸ‘Œ

from gym-pybullet-drones.

Cakhavan avatar Cakhavan commented on July 18, 2024

Awesome yeah it seems to be the case. I modified the code slightly to get some quick results:

in BaseSingleAgentAviary.py I commented out lines 86-91 and replaced it with:

self.ctrl = [DSLPIDControl(CtrlAviary(drone_model=DroneModel.CF2X,
num_drones=1,
initial_xyzs=None,
initial_rpys=None,
physics=Physics.PYB,
neighbourhood_radius=10,
freq=240,
aggregate_phy_steps=int(240/48),
gui=False,
record=False,
obstacles=False,
user_debug_gui=Falsegym_pybullet_drones/envs/single_agent_rl/BaseSingleAgentAviary.py
)) for i in range(1)]

Not sure if this helps anything, but at least the code doesnt break and it seems to be doing some learning as well.

Hope this helps in some way!

from gym-pybullet-drones.

JacopoPan avatar JacopoPan commented on July 18, 2024

Yes, just giving any instance of an aviary (using the same drone model as the desired one) would work.
But I think we can agree it's ugly and wastefulπŸ˜….
It's a usage I hadn't initially planned for and now requires some re-thinking of the control superclass, mostly for the sake of readability .

from gym-pybullet-drones.

JacopoPan avatar JacopoPan commented on July 18, 2024

I have modified how control classes are initialized, so that only a drone model (and not an environment would be required)

from gym-pybullet-drones.

shangjiayong avatar shangjiayong commented on July 18, 2024

Excuse me, @JacopoPan, @Cakhavan. I'm a little confused. For now, does "execute singleagent.py with actiontype: pid, env: hoveraviary" mean "use pid to control a single drone for a hover task"? Thanks for your time.

from gym-pybullet-drones.

JacopoPan avatar JacopoPan commented on July 18, 2024

@shangjiayong yes, a PID position (relative to that of the drone in world frame) controller

from gym-pybullet-drones.

shangjiayong avatar shangjiayong commented on July 18, 2024

@JacopoPan Thank you for your answer. However, when I use PID as actiontype, the console output contains the calculated reward. It looks like the reinforcement learning method is still working. This makes me a bit confused.

from gym-pybullet-drones.

JacopoPan avatar JacopoPan commented on July 18, 2024

@shangjiayong
PID action type means that the input to the aviary/environment/pybullet simulation are position references but if you use singleagent.py you are still using RL, if you want to explicitly command the drone, look at the fly.py and velocity.py scripts.

from gym-pybullet-drones.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.