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

Unable to Change VehicleMode to "GUIDED" in Python DroneKit Script #1215

Open
ViniciusHansen opened this issue Jan 10, 2024 · 1 comment
Open

Comments

@ViniciusHansen
Copy link

I am facing an issue in my Python script using the DroneKit library, specifically with changing the VehicleMode to "GUIDED." The script seems to be stuck in the "STABILIZE" mode, and despite setting the mode to "GUIDED," it does not take effect.

# ... (existing code)

def arm_and_takeoff(altitude):
   while not vehicle.is_armable:
      print("waiting to be armable")
      time.sleep(1)

   print("Arming motors")
   vehicle.mode = VehicleMode("GUIDED")
   print(vehicle.mode)  # This prints "VehicleMode:STABILIZE" instead of "VehicleMode:GUIDED"
   vehicle.armed = True

   while not vehicle.armed:
      time.sleep(1)

   print("Taking Off")
   vehicle.simple_takeoff(altitude)

   while True:
      v_alt = vehicle.location.global_relative_frame.alt
      print(">> Altitude = %.1f m" % v_alt)
      if v_alt >= altitude - 1.0:
          print("Target altitude reached")
          break
      time.sleep(1)

# ... (rest of the code)

output:

CRITICAL:autopilot:APM:Copter V3.3 (d6053245)
CRITICAL:autopilot:Frame: QUAD
CRITICAL:autopilot:Calibrating barometer
CRITICAL:autopilot:Initialising APM...
CRITICAL:autopilot:barometer calibration complete
CRITICAL:autopilot:GROUND START
waiting to be armable
waiting to be armable
waiting to be armable
waiting to be armable
waiting to be armable
Arming motors
VehicleMode:STABILIZE  <----
ERROR:autopilot:ARMING MOTORS
CRITICAL:autopilot:GROUND START
WARNING:dronekit:Link timeout, no heartbeat in last 5 seconds
CRITICAL:autopilot:Initialising APM...
Taking Off
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
ERROR:autopilot:DISARMING MOTORS
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m
>> Altitude = 0.0 m

conda env:

(dronekit-env) [hnz@aspire-5 ~/startup/Prototipo #0]$ conda list
# packages in environment at /home/hnz/anaconda3/envs/dronekit-env:
#
# Name                    Version                   Build  Channel
_libgcc_mutex             0.1                        main  
_openmp_mutex             5.1                       1_gnu  
ca-certificates           2023.12.12           h06a4308_0  
contourpy                 1.1.1                    pypi_0    pypi
cycler                    0.12.1                   pypi_0    pypi
dronekit                  2.9.2                    pypi_0    pypi
dronekit-sitl             3.3.0                    pypi_0    pypi
empy                      3.3.4                    pypi_0    pypi
fonttools                 4.47.0                   pypi_0    pypi
future                    0.18.3                   pypi_0    pypi
importlib-resources       6.1.1                    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  
lxml                      5.1.0                    pypi_0    pypi
matplotlib                3.7.4                    pypi_0    pypi
mavproxy                  1.8.69                   pypi_0    pypi
monotonic                 1.6                      pypi_0    pypi
ncurses                   6.4                  h6a678d5_0  
numpy                     1.24.4                   pypi_0    pypi
openssl                   3.0.12               h7f8727e_0  
packaging                 23.2                     pypi_0    pypi
pexpect                   4.9.0                    pypi_0    pypi
pillow                    10.2.0                   pypi_0    pypi
pip                       23.3.1           py38h06a4308_0  
psutil                    5.9.7                    pypi_0    pypi
ptyprocess                0.7.0                    pypi_0    pypi
pymavlink                 2.4.41                   pypi_0    pypi
pyparsing                 3.1.1                    pypi_0    pypi
pyserial                  3.5                      pypi_0    pypi
python                    3.8.18               h955ad1f_0  
python-dateutil           2.8.2                    pypi_0    pypi
readline                  8.2                  h5eee18b_0  
screen                    1.0.1                    pypi_0    pypi
setuptools                68.2.2           py38h06a4308_0  
six                       1.16.0                   pypi_0    pypi
sqlite                    3.41.2               h5eee18b_0  
tk                        8.6.12               h1ccaba5_0  
wheel                     0.41.2           py38h06a4308_0  
xz                        5.4.5                h5eee18b_0  
zipp                      3.17.0                   pypi_0    pypi
zlib                      1.2.13               h5eee18b_0  
@GeraltRivskiy
Copy link

Hello! have you been able to solve this problem?

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

2 participants