Skip to content

Add an example code for movement in GUIDED_NOGPS mode#712

Closed
studroid wants to merge 6 commits intodronekit:masterfrom
studroid:master
Closed

Add an example code for movement in GUIDED_NOGPS mode#712
studroid wants to merge 6 commits intodronekit:masterfrom
studroid:master

Conversation

@studroid
Copy link
Copy Markdown
Contributor

@studroid studroid commented Apr 27, 2017

Use this example to test GUIDED_NOGPS mode for attitude and heading changes and take-off.

@studroid studroid mentioned this pull request Apr 27, 2017
Copy link
Copy Markdown
Member

@squilter squilter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the work! I think it would be good if you could write a comment that is a bit more explicit about what the user should expect the vehicle to do. Given that the vehicle will be in Guided-NoGPS mode, a lot of unexpected behavior could occur. It would be helpful to warn anybody that might just try to run this script to see what happens.

@@ -0,0 +1,160 @@
#!/usr/bin/env python
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code clearly only runs with python2. I think it would be best to specify that, so nobody tries to run it and have it fail.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your review, squilter!
I will fix this code to fit into the dronekit until May 6.
It is great to have a chance like this to contribute to the dronekit!

# -*- coding: utf-8 -*-

"""
© Copyright 2017, Team OpenMakerDrone at Yonsei Univ.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might be a problem with the license and the project rules. Maybe somebody else can weight in.

set_attitude(pitch_angle = -1, thrust = 0.5, duration = 3)


print("Setting LAND mode...")
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistent use of print "something"and print("something")

@studroid
Copy link
Copy Markdown
Contributor Author

studroid commented May 7, 2017

@squilter I think it may work with Python 3 now, but I also specified the testing condition I used.
Thank you for your concrete feedback!

@studroid
Copy link
Copy Markdown
Contributor Author

Hello, is there anyone who can give me feedback or can merge this one?

@hamishwillee
Copy link
Copy Markdown
Contributor

@mrpollo I don't know anything about indoor mode - can you comment on this?

@studroid Without trying this my only thought is that it would be good if it came with some docs - like this: http://python.dronekit.io/examples/simple_goto.html

The aim is to make it very easy for people to run your example - what are its dependencies? How does it work? What should happen if it is working? What is the special sauce that makes it work (in this case the new mode for AC3.3?). What it can't do that people might expect.

That sort of thing.

@studroid
Copy link
Copy Markdown
Contributor Author

studroid commented Jun 8, 2017

Thank you for the suggestion, @hamishwillee !

I will try to write the explanation about the code, and if any of you can review my code, it would be a great help when writing the docs, which can lead me to write about specific warning point for users.

I'm sure many users are waiting for using dronekit for GUIDED_NOGPS mode.

@hamishwillee
Copy link
Copy Markdown
Contributor

I am certain that users would like some real examples of GUIDED_NOGPS mode. I'm pretty busy in the next 2 months, but I'll see what I can do to review docs - and that will involve testing this example.

Copy link
Copy Markdown
Contributor

@deb0ch deb0ch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this code example ! It made my life a lot easier for getting started with SEND_ATTITUDE_TARGET messages.

I would have struggled a lot more without it 👍

"""
Note that from AC3.3 the message should be re-sent every second (after about 3 seconds
with no message the velocity will drop back to zero). In AC3.2.1 and earlier the specified
velocity persists until it is canceled. The code below should work on either version
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace the word "velocity" by "angle" here. When in angle control mode, GUIDED doesn't care about velocity or any information that might come from the gps. The same functions as for ALT_HOLD or STABILIZE are used internally by Ardupilot to control the drone.

time.sleep(0.2)


def set_attitude(roll_angle = 0.0, pitch_angle = 0.0, yaw_rate = 0.0, thrust = 0.5, duration = 0):
Copy link
Copy Markdown
Contributor

@deb0ch deb0ch Jul 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't add a yaw_angle argument here, the drone will always abruptly flip to that yaw angle (being zero) as soon as you call this function.

In my instance of using this code I initialize the yaw_angle argument that I'm passing to this function to the drone's current yaw, so that it just keeps its current yaw.

# Thrust > 0.5: Ascend
# Thrust == 0.5: Hold the altitude
# Thrust < 0.5: Descend
msg = vehicle.message_factory.set_attitude_target_encode(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why skip a line here ? 😸

# Sleep for the fractional part
time.sleep(modf[0])

# Send command to vehicle on 1 Hz cycle
Copy link
Copy Markdown
Contributor

@deb0ch deb0ch Jul 9, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although the timeout for velocity control in GUIDED is 3s, the timeout for angle control in GUIDED and GUIDED_NOGPS is only 1s. Given that, it might be cleaner to increase this rate to, say, 2Hz or so to make sure to never accidentally trigger a timeout even briefly.

This different timeout is also not documented (that I have seen), so it might be worthy to mention it in a comment.

Note also that it will add 1s to the duration passed as an argument, so you might want to take that into account or warn the user that the actual duration will be 1s more than what he gave as an argument.

@studroid
Copy link
Copy Markdown
Contributor Author

@deb0ch Really good to hear that! :) 👍
And also thank you for your great feedback. I will review it and apply them soon while writing some docs.

@amilcarlucas
Copy link
Copy Markdown
Contributor

ping... almost 4 months have passed :(

@hamishwillee
Copy link
Copy Markdown
Contributor

@peterbarker @mrpollo Do you have any comments on this? DK-Python is not currently on my priority list.

One thought, the folder and filename are not useful - change_attitude.py
ie do you think someone would find this example if looking for examples of NO_GPS?

@deb0ch
Copy link
Copy Markdown
Contributor

deb0ch commented Nov 4, 2017

examples/guided_nogps/guided_nogps_example.py ?

@SJKim0122
Copy link
Copy Markdown

Thank you for your ping, @amilcarlucas :)
I've been busy too for the last 4 months and almost forgot about this.

It seems I can keep working on this request after next week, so let me know if any modification is required.

@hamishwillee
Copy link
Copy Markdown
Contributor

Probably

examples/guided_nogps/guided_nogps.py ?

@amilcarlucas
Copy link
Copy Markdown
Contributor

One more month ....

@hamishwillee
Copy link
Copy Markdown
Contributor

See #712 (comment) . I don't know of the technical merits of the code, but naming it something that means people can identify it easily is a good idea.

@deb0ch
Copy link
Copy Markdown
Contributor

deb0ch commented Dec 4, 2017

@hamishwillee Do you mean that you are waiting for @studroid to integrate the changes for merging this ?

@hamishwillee
Copy link
Copy Markdown
Contributor

No, I'm not planning on merging it because I don't have time to review it right now. But if I was to put a gating factor, that would be one.

@peterbarker Is best person to comment on this.

@SJKim0122
Copy link
Copy Markdown

Thank you for all of your interest on this, and sorry for being late.
I can work on this on this Wednesday evening and will integrate the changes until then, and also try to make a document.

If any of you can make a change to this request, please make a push or pull request and I will integrate it as soon as possible.

Also, It would be great if someone who can merge this gives me feedback, while I know it is a little hard to test because it is a little far from concerns of dronekit, but I'm sure it can help so many dronekit users because there is arising demands for autonomous controlling UAV without GPS :).

@peterbarker
Copy link
Copy Markdown
Contributor

Thanks very much for this example. I do have rights to merge, and I'm only slightly afraid to use them.

I've pushed up a squashed and mildly patched version of this here:

https://github.com/peterbarker/dronekit-python/commits/studroid/guided-nogps

Could you have a quick look at that and say whether you're happy for me to squash all of that together and push it into master, please?

@studroid
Copy link
Copy Markdown
Contributor Author

studroid commented Dec 5, 2017

Hello, @peterbarker ! Sorry if you are confused because I'm using two different accounts, this and @SJKim0122 .
I will use this one only from now on.

Your modifications are really great, and I made just one comment on the code.
Also, I think I have to review in more detail about what @deb0ch mentioned.

Maybe tomorrow would be enough to review them, and some more time needed to write some docs.

@peterbarker
Copy link
Copy Markdown
Contributor

peterbarker commented Dec 5, 2017 via email

@peterbarker peterbarker closed this Dec 5, 2017
@deb0ch
Copy link
Copy Markdown
Contributor

deb0ch commented Dec 5, 2017

Just to give some context to my comments, I'm using the set_attitude_target message in a production project. I use it to control my drone's position based on the output of a lidar, and based my code off of this example.

So I went through it IRL and all the comments that I made are based on caveats that I encountered, and I have real life testing feedback if you guys need.

@deb0ch
Copy link
Copy Markdown
Contributor

deb0ch commented Dec 5, 2017

Oh, and thanks @peterbarker for merging this, it's giving this example PR some needed movement forward 👍

@peterbarker
Copy link
Copy Markdown
Contributor

peterbarker commented Dec 5, 2017 via email

@studroid
Copy link
Copy Markdown
Contributor Author

studroid commented Dec 8, 2017

Thank you for merging this, @peterbarker , and also thank you again, @deb0ch . :)

As @peterbarker mentioned, I think some of @deb0ch 's modifications, such as abrupt yaw flip issue, are remaining to be reviewed.

I can modify them, but could you tell me how I can push up the changes If I make them? I don't know how to do on the closed pull request. Maybe just push them to my repository?

Also, what do you think of renaming to guided_nogps.py like @hamishwillee mentioned at #712 (comment)

By the way, @deb0ch , what kind of project are you working for now? It is just out of curiosity :)
I have no idea about the production project yet, but it will be definitely great if I can help you in any way.

@deb0ch
Copy link
Copy Markdown
Contributor

deb0ch commented Dec 8, 2017

All the changes that you mentioned you can make them in a new PR, since it is the designated way to propose changes to what is already in the codebase (though I'm not related to the DK team, so this is just my humble advice).

Our project is about wind turbines inspection 😸

We are making a drone use a lidar to position itself around a blade of a wind turbine (which is stopped during inspection) for helping the pilot not to crash his drone into the turbine and automatically trigger HD photo captures just at the right distance.

Originally we were using a Erle Brain but this platform was just too, way too unstable. So unstable that it was impossible to have a secure, reliable flight with this one (without mentioning the literally random system bugs), so we are now switching to a pixhawk + raspi-raspbian combo.

I don't know what you're doing or how you could help but any insight is always very welcomed 😺

@peterbarker
Copy link
Copy Markdown
Contributor

peterbarker commented Dec 9, 2017 via email

@ghost
Copy link
Copy Markdown

ghost commented Dec 28, 2017

It is not taking off everytime shows that Altitude=0.0 and nothing happens in loop please help?

@studroid
Copy link
Copy Markdown
Contributor Author

@Arpit355 Are you using SITL or actual Pixhawk-based UAV?
Also, Please let me know the ArduCopter version you are using.

I think it would be better to write your request as an issue and mention this pull-request and me, because it's already been merged. :)

@ghost
Copy link
Copy Markdown

ghost commented Dec 29, 2017

@studroid Arpit here I am using arducopter 3.3.0 and in SITL

@vidyasagar999
Copy link
Copy Markdown

@Arpit355 i found the same issue in SITL. Did you try on a real drone/plane? what was the result?

I am trying to make a line following hexcopter using raspberry and pixhawk. I am able to set GUIDED_NOGPS by messing with mavlink(i am newbie). When i run the example script in SITL, it does arm but doesn't take off. It waits for a few seconds and disarms. I don't understand what it means. I am running on a deadline. Any help would be appreciated. Thanks in advance

@studroid
Copy link
Copy Markdown
Contributor Author

studroid commented Jan 7, 2018

I think you have to use V3.4.4 or later Arducopter version to properly use GUIDED_NOGPS mode.
Also, pymavlink library should support GUIDED_NOGPS or you have to modify the source. (FYI, the latest version of pymavlink supports GUIDED_NOGPS).

Please write an issue using 'issues' tab if you need any further information, so others can find the answers. :)

@ghost
Copy link
Copy Markdown

ghost commented Jan 7, 2018

How to update ArduCopter to version 3.4.4

@ghost
Copy link
Copy Markdown

ghost commented Jan 7, 2018

@studroid how to update ArduCopter version

@hamishwillee
Copy link
Copy Markdown
Contributor

@Arpit355 Please never ever just add your requests to closed issues. It is very frustrating for everyone involved. The right thing to do is to ask on the discussion forums.

That said, the answer is that this has nothing to do with DK-Python. If you're working on hardware you'll update the hardware using Mission Planner or QGroundControl. If you're working with a simulator you'll update to recent codelines and rebuild the simulator http://ardupilot.org/dev/docs/sitl-simulator-software-in-the-loop.html#sitl-simulator-software-in-the-loop

@dronekit dronekit locked and limited conversation to collaborators Jan 7, 2018
@dronekit dronekit unlocked this conversation Jan 7, 2018
@dronekit dronekit locked as resolved and limited conversation to collaborators Jan 7, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants