How to make the simulated drone flip

Use several commands in sequence as follows: TakeOff, MoveBy, Flip, Land.

The question is the simulated drone can take off, move and land, but I cannot see it flipping.

NO ERROR IS REPORTED

Wondering the reason.

THANKS in advance

HERE is the code:
import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, moveBy, Landing
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged
from olympe.messages.ardrone3.Animations import Flip
drone = olympe.Drone(“10.202.0.1”)
drone.connection()
drone(
TakeOff()
>> FlyingStateChanged(state=“hovering”, _timeout=5)
).wait()
drone(
moveBy(5, 5, 0, 0)
>> FlyingStateChanged(state=“hovering”, _timeout=5)
).wait()
drone(
Flip(0,_timeout=5, _no_expect=False, _float_tol=(1e-07, 1e-09))
>> FlyingStateChanged(state=“hovering”, _timeout=5)
).wait()
drone(Landing()).wait()
drone.disconnection()

1 Like

Hi,

What type of drone are you using?
This should only work with a Bebop drone.
The Anafi does not know how to flip and will simply ignore the Flip command message.

Nicolas

Hello,

I use simulated drone in Parrot-Sphinx.
I think I get the point, the simulated is ANAFI

Thank you a lot!

By the way, do you know any way to simulate the Bebop drone?
I followed the tutorial on the website and ANAFI seems to the default one.

Hi again,

Just use the Bebop 2 drone file instead of anafi4k.drone :slight_smile:
sphinx /opt/parrot-sphinx/usr/share/sphinx/drones/bebop2.drone

Nicolas

Thanks a lot!

Excuse me, again

I am sorry, but do you the default IP address of simulated Bebop? I did not find on this website.
Besides, do ANAFI and Bebop share the same function command or I need to download another library specifically for Bebop?

Liu

No need to apologize. I’m sorry but I just forget to tell you one important piece of advice.
For Bebop drones, the drone type has to be given to the olympe.Drone class constructor :

import olympe
import olympe_deps as od
drone = olympe.Drone("10.202.0.1", drone_type=od.ARSDK_DEVICE_TYPE_BEBOP_2)

the default drone simulated IP address (10.202.0.1) does not change.

Let me know if that works for you.
Please note that unlike Anafi, Bebop drone support in Olympe is provided on a best effort basis.

Nicolas

It works!
Thank you so much! You help me a lot

Hello ndessart,
Is what you said still relevant if I want to connect to a physical drone ? Im trying to reach my parrot bebop 2 but it says the IP isnt correct, even though im using the IP that shows up in the drone’s wifi properties.I tried with and without the code ```
import olympe_deps as od
drone = olympe.Drone(“my ip”, drone_type=od.ARSDK_DEVICE_TYPE_BEBOP_2)

This is the main part of what is returned 
08/07/2019 18:30:56.602504	_connecting_cb                  Connecting to device: drone_under_test
08/07/2019 18:30:56.603970	_connect_to_device              Connection in progress...
08/07/2019 18:30:56.605135	_inject_device_to_raw_discovery Device manually added to raw discovery
08/07/2019 18:30:58.610878	_backend_socket_cb              backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7fa2f667cd90> socket_fd 12 socket_kind 1 userdate_pointer None
08/07/2019 18:31:00.617616	_backend_socket_cb              backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7fa2f667cd90> socket_fd 12 socket_kind 1 userdate_pointer None
I arsdkctrl: discovery 'raw': remove device name='drone_under_test' id='000000000'
I arsdkctrl: internally disconnect device name='drone_under_test' type=BEBOP_2 id='000000000'
08/07/2019 18:31:01.675813	connection                      Unable to connect to the device. IP : b'192.168.42.44' 
Traceback (most recent call last):
  File "takeoff.py", line 11, in <module>
    >> FlyingStateChanged(state="hovering", _timeout=10)
NameError: name 'FlyingStateChanged' is not defined
08/07/2019 18:31:01.682798	_canceled_cb                    Connection to device: <ctypes.LP_c_char object at 0x7fa2f667cae8> has been canceled for reason: LOCAL
08/07/2019 18:31:01.789429	_device_removed_cb              Device has been removed
08/07/2019 18:31:01.793711	_stop_discovery                 Device removed from discovery
I arsdkctrl: discovery 'raw': stop
08/07/2019 18:31:01.796857	_stop_discovery                 Discovery has been stopped

It seems that your problem is that you do not define the function FlyingStateChanged()
Please add this: from olympe.messages.ardrone3.PilotingState import FlyingStateChanged

Liu

Thank you for your reply

Traceback (most recent call last):
File “takeoff.py”, line 3, in
from olympe.messages.ardrone3.PilotingState import FlyingStateChange
ImportError: cannot import name ‘FlyingStateChange’

Thats the error it returns. Here is the python code:

import olympe
from olympe.messages.ardrone3.Piloting import TakeOff, Landing
from olympe.messages.ardrone3.PilotingState import FlyingStateChange

import olympe_deps as od

drone = olympe.Drone(“192.168.42.44”, drone_type=od.ARSDK_DEVICE_TYPE_BEBOP_2)
drone.connection()
drone(
TakeOff()

FlyingStateChanged(state=“hovering”, _timeout=10)
).wait()
drone(Landing()).wait()
drone.disconnection()

Hello

You miss the letter ‘d’

It is FlyingStateChanged not FlyingStateChange
It should work after you add ‘d’

Please inform me if it works

Sorry :sweat_smile:

But it still wont connect

08/07/2019 19:11:11.255789 _create_pomp_loop Creating pomp loop
08/07/2019 19:11:11.257151 _create_manager New manager has been created!
08/07/2019 19:11:11.257761 _create_manager Manager device callbacks has been added to the manager
08/07/2019 19:11:11.258593 _create_net_backend New net backend has been created
08/07/2019 19:11:11.259191 _create_net_backend Set backend socket callback OK
08/07/2019 19:11:11.259770 create_timer Creating pomp timer
08/07/2019 19:11:11.260520 create_timer Creating pomp timer
08/07/2019 19:11:11.263990 _start_net_discovery Net discovery object has been created
I arsdkctrl: discovery ‘net’: start
08/07/2019 19:11:11.265680 _backend_socket_cb backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7f872d390f28> socket_fd 10 socket_kind 0 userdate_pointer None
08/07/2019 19:11:11.266646 _start_net_discovery Net discovery has been started
08/07/2019 19:11:13.272246 _backend_socket_cb backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7f872d380400> socket_fd 10 socket_kind 0 userdate_pointer None
08/07/2019 19:11:15.276597 _backend_socket_cb backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7f872d380400> socket_fd 10 socket_kind 0 userdate_pointer None
I arsdkctrl: discovery ‘net’: stop
08/07/2019 19:11:16.350050 connection trying to bypass discovery using device {‘name’: b’drone_under_test’, ‘addr’: b’192.168.42.44’, ‘port’: 44444, ‘dronetype’: 2316, ‘serialnb’: b’000000000’}
08/07/2019 19:11:16.354364 _stop_discovery Discovery has been stopped
08/07/2019 19:11:16.355787 _stop_discovery Discovery object has been destroyed
08/07/2019 19:11:16.357174 _start_raw_discovery discovery object has been created
I arsdkctrl: discovery ‘raw’: start
08/07/2019 19:11:16.358196 _start_raw_discovery discovery started
I arsdkctrl: discovery ‘raw’: add device name=‘drone_under_test’ id=‘000000000’
08/07/2019 19:11:16.363167 _device_added_cb New device has been detected
08/07/2019 19:11:16.364714 _device_added_cb {‘state’: 0}
08/07/2019 19:11:16.367759 _backend_socket_cb backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7f872cb5ce18> socket_fd 11 socket_kind 2 userdate_pointer None
08/07/2019 19:11:16.369636 _backend_socket_cb backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7f872cb5ce18> socket_fd 12 socket_kind 1 userdate_pointer None
08/07/2019 19:11:16.371318 _connecting_cb Connecting to device: drone_under_test
08/07/2019 19:11:16.375147 _connect_to_device Connection in progress…
08/07/2019 19:11:16.376092 _inject_device_to_raw_discovery Device manually added to raw discovery
08/07/2019 19:11:18.378828 _backend_socket_cb backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7f872cb5cd90> socket_fd 12 socket_kind 1 userdate_pointer None
08/07/2019 19:11:20.384795 _backend_socket_cb backend_pointer <olympe_deps.LP_struct_arsdkctrl_backend_net object at 0x7f872cb5cd90> socket_fd 12 socket_kind 1 userdate_pointer None
I arsdkctrl: discovery ‘raw’: remove device name=‘drone_under_test’ id=‘000000000’
I arsdkctrl: internally disconnect device name=‘drone_under_test’ type=BEBOP_2 id=‘000000000’
08/07/2019 19:11:21.444743 connection Unable to connect to the device. IP : b’192.168.42.44’
08/07/2019 19:11:21.452983 _canceled_cb Connection to device: <ctypes.LP_c_char object at 0x7f872cb071e0> has been canceled for reason: LOCAL
08/07/2019 19:11:21.558604 _device_removed_cb Device has been removed
08/07/2019 19:11:21.562395 _stop_discovery Device removed from discovery
I arsdkctrl: discovery ‘raw’: stop
08/07/2019 19:11:21.566258 _stop_discovery Discovery has been stopped
08/07/2019 19:11:21.567572 _stop_discovery Discovery object has been destroyed
08/07/2019 19:11:21.573341 _send_command Ardrone3.Piloting.TakeOff(): has been sent asynchronously
Traceback (most recent call last):
File “/home/alpha/code/parrot-groundsdk/packages/olympe/src/olympe/_private/pomp_loop_thread.py”, line 203, in _run_task_list
ret = f(*args, **kwargs)
File “/home/alpha/code/parrot-groundsdk/packages/olympe/src/olympe/arsdkng/drone.py”, line 872, in _send_command_impl
raise RuntimeError("[sendcmd] Error cmd interface seems to be destroyed")
RuntimeError: [sendcmd] Error cmd interface seems to be destroyed
08/07/2019 19:11:21.576156 _stop_discovery No discovery instance to be stopped
08/07/2019 19:11:21.583256 _stop_discovery No discovery instance to be stopped
08/07/2019 19:11:21.589306 _send_command Ardrone3.Piloting.Landing(): has been sent asynchronously
Traceback (most recent call last):
File “/home/alpha/code/parrot-groundsdk/packages/olympe/src/olympe/_private/pomp_loop_thread.py”, line 203, in _run_task_list
ret = f(*args, **kwargs)
File “/home/alpha/code/parrot-groundsdk/packages/olympe/src/olympe/arsdkng/drone.py”, line 872, in _send_command_impl
raise RuntimeError("[sendcmd] Error cmd interface seems to be destroyed")
RuntimeError: [sendcmd] Error cmd interface seems to be destroyed
08/07/2019 19:11:31.613217 _stop_discovery No discovery instance to be stopped
08/07/2019 19:11:31.617874 _destroy_net_backend Net backend has been destroyed
08/07/2019 19:11:31.619198 _destroy_manager Manager has been destroyed
08/07/2019 19:11:31.620591 destroy_timer Pomp loop timer has been destroyed
08/07/2019 19:11:31.621776 destroy_timer Pomp loop timer has been destroyed
08/07/2019 19:11:31.622705 _destroy_pomp_loop Pomp loop has been destroyed

If you are trying to connect to a physical drone over wifi, the IP address should be 192.168.42.1
For a simulated drone, the IP address is 10.202.0.1.

Please, create a new thread if that does not solve your problem. Thanks

Thank you very much it worked !

Hello ndessart,

I am now trying the function circle using bebop. I can see the command is processed in the terminal but I cannot see the drone doing any activities, wondering the reason.

Thanks in advance.
Here is the code:
import olympe
import olympe_deps as od
from olympe.messages.ardrone3.Piloting import TakeOff, moveBy, Landing, Circle
from olympe.messages.ardrone3.PilotingState import FlyingStateChanged
from olympe.messages.ardrone3.Animations import Flip
drone = olympe.Drone(“10.202.0.1”,drone_type=od.ARSDK_DEVICE_TYPE_BEBOP_2)
drone.connection()
drone(TakeOff()>> FlyingStateChanged(state=“hovering”, _timeout=5)).wait()
drone(moveBy(5, 5, 0, 0)>> FlyingStateChanged(state=“hovering”, _timeout=5)).wait()
drone(Circle(0)>> FlyingStateChanged(state=“hovering”, _timeout=5)).wait()
drone(Landing()).wait()

Here is what is shown in terminal:

10/07/2019 01:20:27.449785 _send_command Ardrone3.Piloting.Circle(c_uint(0),): has been sent asynchronously
10/07/2019 01:20:27.567298 _recv_cmd_cb ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=12)
10/07/2019 01:20:27.677021 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:27.840010 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:28.066817 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:28.252253 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:28.459398 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:28.600354 _recv_cmd_cb ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=12)
10/07/2019 01:20:28.704098 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:28.867497 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:29.096182 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:29.282554 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:29.485535 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)
10/07/2019 01:20:29.628639 _recv_cmd_cb ardrone3.GPSState.NumberOfSatelliteChanged(numberOfSatellite=12)
10/07/2019 01:20:29.736970 _recv_cmd_cb ardrone3.CameraState.Orientation(tilt=-13, pan=0)

Hi,

The Circle command is only meaningful for a fixed wing drone (i.e. Parrot Disco). This command is ignored by every other drone.

From the documentation of this Circule command :

Make the fixed wing circle. The circle will use the CirclingAltitudeChanged() and the CirclingRadiusChanged()

I give you that we should make things more explicit about which commands are supported by each of our drones.

Thank you ndessart

Do you how to connect to the simulated disco drone?
I run this code
drone =olympe.Drone(“10.202.0.1”,drone_type=od.ARSDK_DEVICE_TYPE_DISCO)
but maybe I mistake the type, it does not work.

Regards

Hi,

You should just have to connect to the simulated disco, “shake hit” to simulate a hand launch and then send the usual takeoff command.

drone =olympe.Drone(“10.202.0.1”,drone_type=od.ARSDK_DEVICE_TYPE_DISCO)
drone.connection()
# send a "shake" request to the simulator here as explained in the Sphinx documentation
drone(TakeOff()).wait()

Regards

Nicolas