-
Notifications
You must be signed in to change notification settings - Fork 119
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
Some examples using DroneKit and Python to fly the DJI drones... #36
Comments
PS: If you use the GOTO function in QGC you MUST move more than 50cm or it will ignore the command (a DJI thing). |
This might sound trivial but could you make a basic tutorial for this ? once you have rosetta drone working and are able to do a QGC mission, where would i start to use this? my goal is to add a python VoiceBot to automatically handle take off, landing, and assignment of missions. |
I will, I am working on mission plans from QGC now, the goal is to have this working before Christmas.
… On 7 Dec 2020, at 22:07, danammeansbear ***@***.***> wrote:
This might sound trivial but could you make a basic tutorial for this ? once you have rosetta drone working and are able to do a QGC mission, where would i start to use this? my goal is to add a python VoiceBot to automatically handle take off, landing, and assignment of missions.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#36 (comment)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABS7SLFUGSRYHQDWRGKKJODSTU7ZZANCNFSM4UMVFFPQ>.
|
Thanks @The1only ,it's a very useful tutorial on controlling drone using python. Best, |
All the information about using the Python DroneKit to control RosettaDrone2 is here: https://dronekit-python.readthedocs.io/en/latest/ And this very nice class that explains everything in detail: https://www.udemy.com/course/drone-programming-primer-for-software-development/ It will eventually be 100% Mavlink compatible, so wether you fly DJI or a Mavlink drone it should be the same. |
Ahhhh I know you're problem, you MUST unlock the system ( for safety) hitt the small lock button up on the right side, when it is white, THEN you can take off.... Just to prevent accidental takeoffs. And PS: It is always smart to enter the simulation mode, and tese that everything works before actually flying. Just hit the sim button and take off... :-) |
Hi All, following a very simple python script that connects to RosettaDrone and print out some vehicle parameters: Usage: your_gcs_ip_address is the address of the computer where the script is running I'll post also a more complex script with some commands like takeoff , starting a mission and so on Ciao /Luca
|
Perfekt, I work round the clock to get the mission planning working. The conversion from Mavlink to DJI and back is almost ready. |
This is awesome 👌
…On Thu, Dec 17, 2020, 1:52 PM Terje ***@***.***> wrote:
Perfekt, I work round the clock to get the mission planning working. The
conversion from Mavlink to DJI and back is almost ready.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#36 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AHJKTGNMBWGCTBXURHGSIMTSVJHQFANCNFSM4UMVFFPQ>
.
|
Awesome!!! |
We are stuck in change mode from Stabilize to GUIDED. (by using the command To our knowledge, drone can not be armable without going to GUIDED mode. Hope to hear your expertise. Best, ps: we are testing DJI mini. |
If I remember right the DJI drone switches automatically on a takeoff command from mavlink, ignore the error and continue to takeoff. But RosettaDrone expect 'P' mode on the controller (Mavic 2 Pro), and you must click on the "lock" so it becomes white NOT geeen before issuing the command.
|
Thanks for your persistently kind help, @The1only . By ignore mode change and arm check, we are able to takeoff ! ===
We are working on virtual joytick and a simple control feature based on your example. Best, |
PS: remember that if you hit the SIM button on startup you can take off and fly like this without actually taking off. The SIM button enables the built inn DJI HITL module. The drone must be rebooted after using the Simulation mode. |
Nice to know the feature !
inside the mavlink packet. If you know any help manual on mavlink msg construction, please kindly let us know. Thanks, |
|
In QGC you can also point and click on the location you want the drone to "goto" and it will. |
The problem we met is VehicleMode doesn't take effect. We've tested multiple VehicleMode such as GUIDED, LAND, but none of them is successfully set. Alternatively, vehicle.send_mavlink(msg) works. Since Rosetta Drone has MAV_CMD dictionary, so maybe we could send command to corresponding mission, s.t. MAV_CMD_NAV_LAND = 21; Hope to hear your expertise. Best, |
Hmm strange I have been using this code for over one year now without issues. Let me look into it. No works fine, both RTL and LAND commands are OK. If you are used to PX4 or Ardupilot, do not get too hooked up in how the mode changes work, DJI does this totally different. The DJI drone itself controls mode changes, so the RosettaDrone convert mode changes to commands, like land or return to launsh. You can not directly SET a mode change. Also DJI handles RTL strange if you do not fly more than 10 meters or so from takeoff, then they simply land I've noticed, |
Thanks for your prompt reply. |
It's allready there, just select the LOGCAT windows and enter MAV in the text window and select Verbose... |
We found that MAV_CMD_DO_SET_MODE cause the issue, so we logcat it:
Then Rosetta Drone executes That's weird, param1 is 1.0 (it's the altitude); But param2 is 9, which seems matches LAND code better. Hope to hear your expertise on the parameter discrepancy. Does it cause by different mavlink protocol used in different DJI model ? -- Luke |
Can you provide a short test case that recreates this problem? https://mavlink.io/en/messages/common.html The only modes that will have any effect are these: And at the moment the only ones that are confirmed to work is: As we still work on the waypoint functionality. |
The python code of dronekit is below. VehicleMode("LAND") send command 176 to RosettaDrone, and RosettaDrone uses command 176 to do the case MAV_CMD_DO_SET_MODE, and then changeFlightMode((int) msg_cmd.param2) needs to use to set proper mode for RosettaDrone. The long command is: Not sure why LAND parameter (9.0) is not put in param 1. It's put in 2 for Custom Mode.
|
You are on to something, thank you. On my MAC with all the latest modules, I get the same issue as you, that is, the Mode change command uses parameter 2, as it should. When I change the code to use parameter 2 rather than 1 then all the mode changes work again and I can take off and land. Greate catch... |
I used a setup from a Udemy class years ago... |
If you check out the “Work” branch it is fixed.
I now uses Parameter 2 and can confirm it works on my MAC with all the latest.
But now it’s a problem on older systems.
|
Thanks for your fix, @The1only ! We are working on velocity control, regards to your example "Send a velocity command with +x being the heading of the drone." on the top of the discussion thread: What is And the line: Best, |
We're experiencing the same issues: from python script, we're able to takeoff and go to specified lat,lon We've also an issue with goto command, the altitude will change to 1.2m We're unable to issue command like RTL or LAND too |
Hmm We just fixed RTL did we not??? Sorry for the bad example, I updated it now. |
I used mavproxy too for splitting mavlink stream to qgcs and my REST API scripts |
I've tested sending RTH change mode (the same I use in my python script) but Rosetta Drone does not respond { "header": { "system_id": 1, "component_id": 1, "sequence": 0 }, "message": { "type":"COMMAND_LONG", "param1":1.0, "param2":6.0,"param3":0.0,"param4":0.0,"param5":0.0,"param6":0.0,"param7":0.0, "command":{ "type":"MAV_CMD_DO_SET_MODE" }, "target_system":0, "target_component":0, "confirmation":0 } } |
Nice project, There are several manuals for dronekit online. You will find everything there, combined with this page.
I will make a manual/wikki at some time, but now I got no time.
|
Try the Work branch, it got some nice fixes.
If you got problems I’ll jump right at it.
Best regard
Terje Nilsen
9Tek AS
Norway
… On Dec 21, 2020, at 17:01, ADPM Drones ***@***.***> wrote:
Take your time, thank you
With the master branch, the GOTO command worked with the altitude issue
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Just use takeoff goto(lat lon) rtl()
It’s all described in the DeonKit for python manual by 3DR.
Best regard
Terje Nilsen
9Tek AS
Norway
… On Jan 13, 2021, at 18:46, danammeansbear ***@***.***> wrote:
Does anyone have an idea how to map out a polygon mission based around a center point EX. creating a rectangle mission pattern based on current or assigned position
I have this script i use to get the distance of one point to another
'
R = 6373.0
radius of the Earth
lat1 = math.radians(52.2296756)
coordinates
lon1 = math.radians(21.0122287)
lat2 = math.radians(52.406374)
lon2 = math.radians(16.9251681)
dlon = lon2 - lon1
change in coordinates
dlat = lat2 - lat1
a = math.sin(dlat / 2)**2 + math.cos(lat1) * math.cos(lat2) * math.sin(dlon / 2)**2
Haversine formula
c = 2 * math.atan2(math.sqrt(a), math.sqrt(1 - a))
distance = R * c
print(distance)
OUTPUT
278.54558935106695
'
and this algorithm with the help of my teacher to get the cordinates of an unknown point give then distance.
The formula is
x2=x1+d×cosθ,y2=y1+d×sinθ,
d = the distance from (x1,x2) to (y1,y2).
How would i algorithmically compute a polygon and assign cordinates to the points of it? sorta like how mission planner does this but command line format
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Dear Dronekit friends, We are trying to use DroneKit's Gimbal function to change the pitch of gimbal, but not very sure if it is compatible with rosettadrone. I was wondering if someone tried DroneKit to control camera gimbal. Hope to know what kind of DJI model works. -- Luke |
No, you have to use Dronekit servo functions. As described in the readme cannel 8 and 9 if I remember right. However send me a Dronekit code example and I will make it work.
|
Great tips @The1only ! We do find below important lines in MAVLinkReceiver which can map to DroneKit Servo control
As we know, do_set_Gimbal is implemented in DroneModel, showing that channel 9 is for pitch control. (8 is for yaw) We are working on Mavic. So just curious about why you said in #14 Mavic might have issue on controlling gimbal, is it fundamentally restricted by DJI SDK ? |
Update @The1only : Good news, we are able to make camera looking down (i.e. bird's view) by changing the servo position between 1500 and 1000. However, we got issue on making the camera looking up. We changed the servo position up to 2000 but there is no response. We are testing DJI mavic mini, codes are below:
-- Luke |
Tilt works fine, but you can not do 2000 that would be stright up, try 1600 and increase.
Pan is the real issue, only work on ground, not in air.
|
Thanks for your reply so that we are able to realize a 5.5 value corresponds to 1 degree tilt. |
Hi, I'm the creator of mavlink2rest, I'm a bit lost, is there any integration for it in this project, is there any work in progress for that or is this an acceptable contribution ? |
I am the creator of Rosettadrone2.
As we do a mavlink2DJI as part of our project, and you do mavlink2rest, som has then done rest to DJI, using both projects. And the reported it working.
You do great work, let’s work more together.
|
Just had a successful test flight with my mavic mini controlled by a artificial intelligence python script to avoid obstacles. First results are promising. Congratulations to "The1only" for this excellent Rossetadrone2 work. |
Dear Dronekit friends, I've successfully connect Rosetta Drone and Dronekit, and use python script to interact with my Drone (Mavic Mini). It works with Any idea how to solve this issue? Thanks. |
Did you find the way? i wanna do something like that with a Mavic Mini |
I would love to have a little guide for that. I’m trying to connect my Mavic Mini |
Read the DroneKit for Python manuals, it’s all there.
Best regard
Terje Nilsen
9Tek AS
Norway
… On Dec 28, 2021, at 21:35, Newguyonthefield ***@***.***> wrote:
This might sound trivial but could you make a basic tutorial for this ? once you have rosetta drone working and are able to do a QGC mission, where would i start to use this? my goal is to add a python VoiceBot to automatically handle take off, landing, and assignment of missions.
Did you find the way? i wanna do something like that with a Mavic Mini
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
Hi @avncalst, I saw your video on YouTube. I'm interested in writing AI scripts for the mini SE. |
Thank you Cristopher,It feels god when someone fully understands ones work. It was presisly this I designed Rosettadrone 2 for. I did AI powerline inspections fully autonomous without any human interaction or pre planning.Best regardTerje Nilsen9Tek ASNorwayOn 9 Jan 2023, at 03:00, Christopher Pereira ***@***.***> wrote:
Just had a successful test flight with my mavic mini controlled by a artificial intelligence python script to avoid obstacles. First results are promising. Congratulations to "The1only" for this excellent Rossetadrone2 work.
Hi @avncalst, I saw your video on YouTube.
Which repo are you using? I saw some reports of problems dealing with the video stream. Have they been fixed?
I'm interested in writing AI scripts for the mini SE.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you were mentioned.Message ID: ***@***.***>
|
Hi @kripper my code can be found on GitHub https://github.com/avncalst/drone_cnn/tree/master/rosetta. I had no problems video streaming using gstreamer. |
Thanks. I will replicate your environment. I'm asking because there is a fork with additional enhancements for Mini 2 here: |
I compiled with Android Studio "The 1 only's" repo june 2021. So the enhancements for the Mini 2 were not yet available |
Do you know if it's possible to control attitude (roll, pitch, yaw)? I tried code from dronekit examples (https://github.com/dronekit/dronekit-python/blob/master/examples/set_attitude_target/set_attitude_target.py), but it does't work, nothing changes |
Closing. Discussion continues here: #133 |
Hi @avncalst, you were probably using a |
##Two somewhat complex example that works is this:
At the moment I do not use TimeLining for absolute motion, so the drone will fly somewhat strange, as the PID in RosettaDrone2 is not tuned, this will be fixed, but there are some yaw issues I need, that complicate things.
HOWEVER, all the motion functionality is supposed to work.
The goal is that everything you can do with QGC or DroneKit and a Mavlink based drone, you should be able to do with any DJI-Mobile SDK supported drone.
All the Mavproxy and other Mavlink tools work.
ALWAYS test with Ardupilot SITL first, then with RosettaDrone2...
Send a velocity command with +x being NOTRH of the drone.
def send_global_ned_velocity(self, vx, vy, vz, yaw):
msg = self.vehicle.message_factory.set_position_target_global_int_encode(
0, # time_boot_ms (not used)
0, 0, # target system, target component
mavutil.mavlink.MAV_FRAME_GLOBAL_RELATIVE_ALT_INT, # frame
0b0000011111000111, # type_mask (only speeds enabled)
0, 0, 0, # x, y, z positions (not used)
vx, vy, vz, # N, E, D velocity in m/s
0, 0, 0, # x, y, z acceleration (not supported yet, ignored in GCS_Mavlink)
0,float(yaw)) # yaw, yaw_rate (not supported yet, ignored in GCS_Mavlink)
self.vehicle.send_mavlink(msg)
The text was updated successfully, but these errors were encountered: