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

How to use 3D Quadrotor with one of the MPC algorithms? #146

Closed
hedaniel7 opened this issue Jan 23, 2024 · 6 comments
Closed

How to use 3D Quadrotor with one of the MPC algorithms? #146

hedaniel7 opened this issue Jan 23, 2024 · 6 comments

Comments

@hedaniel7
Copy link

In the examples folder there are no suitable examples for running a MPC algorithm on a 3D drone.

I tried to create my own following the tutorial as a copy of the PID and run

python3 pid/pid_experiment.py     --algo linear_mpc     --task quadrotor     --overrides         ./pid/config_overrides/quadrotor_3D/quadrotor_3D_tracking.yaml

but it doesn't work. Could you please explain this more to me and in the tutorial?

Thank you very much

Daniel

@adamhall
Copy link
Contributor

adamhall commented Jan 23, 2024

Hi Dan,

Thanks for your interest in the repo! To help us help you, can you paste the output you see along with your operating system, a list of your environment (using something like pip3 list or conda list), and the branch you are working on?

Best,

Adam

@adamhall
Copy link
Contributor

You might also want to take a look at discussion #121, and modify it for the 3D quadrotor.

@hedaniel7
Copy link
Author

Hi,

thank you for your reply. I am working on the main branch

This is the terminal output:

(safe) dan@SurfBoard3:~/Projects/safe-control-gym/examples$ python3 pid/pid_experiment.py     --algo linear_mpc     --task quadrotor     --overrides         ./pid/config_overrides/quadrotor_3D/quadrotor_3D_tracking.yaml
pybullet build time: Nov 28 2023 23:45:17
/home/dan/anaconda3/envs/safe/lib/python3.10/site-packages/gymnasium/spaces/box.py:130: UserWarning: WARN: Box bound precision lowered by casting to float32
  gym.logger.warn(f"Box bound precision lowered by casting to {self.dtype}")
startThreads creating 1 threads.
starting thread 0
started thread 0 
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Created GL 3.3 context
Direct GLX rendering context obtained
Making context current
GL_VENDOR=Intel
GL_RENDERER=Mesa Intel(R) Iris(R) Plus Graphics (ICL GT2)
GL_VERSION=4.6 (Core Profile) Mesa 21.2.6
GL_SHADING_LANGUAGE_VERSION=4.60
pthread_getconcurrency()=0
Version = 4.6 (Core Profile) Mesa 21.2.6
Vendor = Intel
Renderer = Mesa Intel(R) Iris(R) Plus Graphics (ICL GT2)
b3Printf: Selected demo: Physics Server
startThreads creating 1 threads.
starting thread 0
started thread 0 
MotionThreadFunc thread started
ven = Intel
Workaround for some crash in the Intel OpenGL driver on Linux/Ubuntu
CasADi - 2024-01-25 14:10:12 WARNING("The options 't0', 'tf', 'grid' and 'output_t0' have been deprecated.
The same functionality is provided by providing additional input arguments to the 'integrator' function, in particular:
 * Call integrator(..., t0, tf, options) for a single output time, or
 * Call integrator(..., t0, grid, options) for multiple grid points.
The legacy 'output_t0' option can be emulated by including or excluding 't0' in 'grid'.
Backwards compatibility is provided in this release only.") [.../casadi/core/integrator.cpp:515]
Traceback (most recent call last):
  File "/home/dan/Projects/safe-control-gym/examples/pid/pid_experiment.py", line 132, in <module>
    run()
  File "/home/dan/Projects/safe-control-gym/examples/pid/pid_experiment.py", line 46, in run
    ctrl = make(config.algo,
  File "/home/dan/Projects/safe-control-gym/safe_control_gym/utils/registration.py", line 125, in make
    return registry.make(idx, *args, **kwargs)
  File "/home/dan/Projects/safe-control-gym/safe_control_gym/utils/registration.py", line 88, in make
    obj = spec.make(*args, **kwargs)
  File "/home/dan/Projects/safe-control-gym/safe_control_gym/utils/registration.py", line 69, in make
    obj = cls(*args, **kwargs)
  File "/home/dan/Projects/safe-control-gym/safe_control_gym/controllers/mpc/linear_mpc.py", line 60, in __init__
    super().__init__(
  File "/home/dan/Projects/safe-control-gym/safe_control_gym/controllers/mpc/mpc.py", line 69, in __init__
    self.constraints, self.state_constraints_sym, self.input_constraints_sym = reset_constraints(self.env.constraints.constraints)
AttributeError: 'NoneType' object has no attribute 'constraints'
ven = Intel
Workaround for some crash in the Intel OpenGL driver on Linux/Ubuntu
numActiveThreads = 0
stopping threads
Thread with taskId 0 exiting
Thread TERMINATED
destroy semaphore
semaphore destroyed
destroy main semaphore
main semaphore destroyed
finished
numActiveThreads = 0
btShutDownExampleBrowser stopping threads
Thread with taskId 0 exiting
Thread TERMINATED
destroy semaphore
semaphore destroyed
destroy main semaphore
main semaphore destroyed

This is my Conda environment:

(safe) dan@SurfBoard3:~/Projects/safe-control-gym/examples$ conda list
# packages in environment at /home/dan/anaconda3/envs/safe:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
absl-py                   2.1.0                    pypi_0    pypi
bzip2                     1.0.8                h7b6447c_0  
ca-certificates           2023.08.22           h06a4308_0    anaconda
cachetools                5.3.2                    pypi_0    pypi
casadi                    3.6.4                    pypi_0    pypi
certifi                   2023.11.17               pypi_0    pypi
cfgv                      3.4.0                    pypi_0    pypi
charset-normalizer        3.3.2                    pypi_0    pypi
clarabel                  0.6.0                    pypi_0    pypi
cloudpickle               3.0.0                    pypi_0    pypi
contourpy                 1.2.0                    pypi_0    pypi
cvxpy                     1.4.2                    pypi_0    pypi
cycler                    0.12.1                   pypi_0    pypi
dict-deep                 4.1.2                    pypi_0    pypi
distlib                   0.3.8                    pypi_0    pypi
ecos                      2.0.12                   pypi_0    pypi
exceptiongroup            1.2.0                    pypi_0    pypi
farama-notifications      0.0.4                    pypi_0    pypi
filelock                  3.13.1                   pypi_0    pypi
fonttools                 4.47.2                   pypi_0    pypi
gmp                       6.2.1                h295c915_3    anaconda
google-auth               2.26.2                   pypi_0    pypi
google-auth-oauthlib      1.2.0                    pypi_0    pypi
gpytorch                  1.11                     pypi_0    pypi
grpcio                    1.60.0                   pypi_0    pypi
gymnasium                 0.28.1                   pypi_0    pypi
identify                  2.5.33                   pypi_0    pypi
idna                      3.6                      pypi_0    pypi
imageio                   2.33.1                   pypi_0    pypi
iniconfig                 2.0.0                    pypi_0    pypi
jax-jumpy                 1.0.0                    pypi_0    pypi
jaxtyping                 0.2.25                   pypi_0    pypi
joblib                    1.3.2                    pypi_0    pypi
kiwisolver                1.4.5                    pypi_0    pypi
ld_impl_linux-64          2.38                 h1181459_1  
libffi                    3.4.4                h6a678d5_0  
libgcc-ng                 11.2.0               h1234567_1  
libgomp                   11.2.0               h1234567_1  
libstdcxx-ng              11.2.0               h1234567_1  
libuuid                   1.41.5               h5eee18b_0  
linear-operator           0.5.2                    pypi_0    pypi
markdown                  3.5.2                    pypi_0    pypi
markupsafe                2.1.4                    pypi_0    pypi
matplotlib                3.8.2                    pypi_0    pypi
mosek                     10.1.22                  pypi_0    pypi
munch                     2.5.0                    pypi_0    pypi
ncurses                   6.4                  h6a678d5_0  
nodeenv                   1.8.0                    pypi_0    pypi
numpy                     1.26.3                   pypi_0    pypi
nvidia-cublas-cu11        11.10.3.66               pypi_0    pypi
nvidia-cuda-nvrtc-cu11    11.7.99                  pypi_0    pypi
nvidia-cuda-runtime-cu11  11.7.99                  pypi_0    pypi
nvidia-cudnn-cu11         8.5.0.96                 pypi_0    pypi
oauthlib                  3.2.2                    pypi_0    pypi
openssl                   3.0.12               h7f8727e_0    anaconda
osqp                      0.6.3                    pypi_0    pypi
packaging                 23.2                     pypi_0    pypi
pillow                    10.2.0                   pypi_0    pypi
pip                       23.3.2                   pypi_0    pypi
platformdirs              4.1.0                    pypi_0    pypi
pluggy                    1.3.0                    pypi_0    pypi
pre-commit                3.6.0                    pypi_0    pypi
protobuf                  4.23.4                   pypi_0    pypi
pyaml                     23.12.0                  pypi_0    pypi
pyasn1                    0.5.1                    pypi_0    pypi
pyasn1-modules            0.3.0                    pypi_0    pypi
pybind11                  2.11.1                   pypi_0    pypi
pybullet                  3.2.6                    pypi_0    pypi
pycddlib                  2.1.7                    pypi_0    pypi
pyparsing                 3.1.1                    pypi_0    pypi
pytest                    7.4.4                    pypi_0    pypi
python                    3.10.13              h955ad1f_0  
python-dateutil           2.8.2                    pypi_0    pypi
pytope                    0.0.4                    pypi_0    pypi
pyyaml                    6.0.1                    pypi_0    pypi
qdldl                     0.1.7.post0              pypi_0    pypi
readline                  8.2                  h5eee18b_0  
requests                  2.31.0                   pypi_0    pypi
requests-oauthlib         1.3.1                    pypi_0    pypi
rsa                       4.9                      pypi_0    pypi
safe-control-gym          2.0.0                    pypi_0    pypi
scikit-learn              1.4.0                    pypi_0    pypi
scikit-optimize           0.9.0                    pypi_0    pypi
scipy                     1.12.0                   pypi_0    pypi
scs                       3.2.4.post1              pypi_0    pypi
setuptools                68.2.2          py310h06a4308_0  
six                       1.16.0                   pypi_0    pypi
sqlite                    3.41.2               h5eee18b_0  
tensorboard               2.15.1                   pypi_0    pypi
tensorboard-data-server   0.7.2                    pypi_0    pypi
termcolor                 1.1.0                    pypi_0    pypi
threadpoolctl             3.2.0                    pypi_0    pypi
tk                        8.6.12               h1ccaba5_0  
tomli                     2.0.1                    pypi_0    pypi
torch                     1.13.1                   pypi_0    pypi
typeguard                 2.13.3                   pypi_0    pypi
typing-extensions         4.9.0                    pypi_0    pypi
tzdata                    2023d                h04d1e81_0  
urllib3                   2.1.0                    pypi_0    pypi
virtualenv                20.25.0                  pypi_0    pypi
werkzeug                  3.0.1                    pypi_0    pypi
wheel                     0.41.2          py310h06a4308_0  
xz                        5.4.5                h5eee18b_0  
zlib                      1.2.13               h5eee18b_0  

I work on Ubuntu 20.04

uname -a Linux SurfBoard3 6.5.6-surface #3 SMP PREEMPT_DYNAMIC Sun Oct 15 20:52:00 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

@Federico-PizarroBejarano
Copy link
Collaborator

@adamhall just added some great example code for MPC to the repo: #148. Let us know if you can run the examples!

@adamhall
Copy link
Contributor

adamhall commented Feb 5, 2024

Hi @hedaniel7,
Did this work for you? We will close the issue if yes.

@adamhall
Copy link
Contributor

Closed for inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants