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

Rover hold/loiter #13767

Merged
merged 1 commit into from
May 13, 2020
Merged

Rover hold/loiter #13767

merged 1 commit into from
May 13, 2020

Conversation

ealdaz-seesai
Copy link
Contributor

This is my first pull request, so unsure as to whether I should raise an Issue before creating a pull request, but I'm hoping that this explanation will be sufficiently clear, any feedback welcome.

Describe problem solved by this pull request
When using HOLD/LOITER the rover would not hold position but instead circle/oscillate around the hold position. This was caused by the fact that the current algorithm sets velocity to zero when distance to waypoint is under a certain threshold, the vehicle would decelerate, but not enough to stop before it once again exceeded the threshold. At this point it would then try to return to the hold position and the process would repeat.

Describe your solution
In the proposed solution once the distance to the waypoint is under a threshold the velocity is set to zero until a new position waypoint is requested that is more than the threshold distance away from the previous waypoint. This way the vehicle always stops.

Test data / coverage
This was tested with both px4_sitl and a pixhawk4 rover running the Aion RObotics R1 UGV (Tank type/Differential drive)

@ealdaz-seesai
Copy link
Contributor Author

This is an example of what happens when selecting HOLD in QGroundControl
image

@ealdaz-seesai
Copy link
Contributor Author

In the proposed implementation the rover stops when HOLD is requested:
image

@julianoes
Copy link
Contributor

@ItsTimmy would be great if you could review this one, thanks!

Copy link
Contributor

@AmeliaEScott AmeliaEScott left a comment

Choose a reason for hiding this comment

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

Overall, this looks like a good solution to the problem. I just think there might be a few artifacts leftover from a merge or something.

src/modules/rover_pos_control/RoverPositionControl.hpp Outdated Show resolved Hide resolved
src/modules/rover_pos_control/RoverPositionControl.cpp Outdated Show resolved Hide resolved
src/modules/rover_pos_control/RoverPositionControl.cpp Outdated Show resolved Hide resolved
@julianoes
Copy link
Contributor

@ealdaz-seesai it would be great if you could follow up on the things @ItsTimmy mentioned and make sure the CI tests pass.

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented Feb 20, 2020 via email

Copy link
Contributor Author

@ealdaz-seesai ealdaz-seesai left a comment

Choose a reason for hiding this comment

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

I've tested it in Gazebo, works as intended

src/modules/rover_pos_control/RoverPositionControl.cpp Outdated Show resolved Hide resolved
src/modules/rover_pos_control/RoverPositionControl.cpp Outdated Show resolved Hide resolved
src/modules/rover_pos_control/RoverPositionControl.hpp Outdated Show resolved Hide resolved
@Jaeyoung-Lim
Copy link
Member

@ealdaz-seesai Could you resolve the conflicts of this PR?

@ealdaz-seesai
Copy link
Contributor Author

Of course, hadn't realized there were conflicts, might be due to some new changes to the file. Let me check.

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented Apr 13, 2020

All tests passing except some MacOS, complaining about implicit conversion from float to double in calls to function get_distance_to_next_waypoint using Vector2f variables
I've made some changes to try to pass those tests

@ealdaz-seesai
Copy link
Contributor Author

Is there anything else required to merge this?

@ealdaz-seesai
Copy link
Contributor Author

bump
@ItsTimmy @dagar @julianoes @Jaeyoung-Lim anything else necessary to merge this?
It seems to me it's ready to go?
Thanks!

Copy link
Contributor

@julianoes julianoes left a comment

Choose a reason for hiding this comment

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

This is changing some submodules. Can you try to rebase on master, or at least merge the latest master into it, fix all conflicts, and make sure the diff is only what you changed?

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented May 4, 2020

Hello Julian
I merged my branch with master 3 weeks ago as some of the files that I had originally modified 4 months ago had been changed since. All tests passed at the time, and couldn't see any conflicts.
Regardless I've merged again without any conflicts.
All checks passed except for the Jenkins Compile MacOS one.
I don't understand what the error is, doesn't seem to be related to my code for what I can tell.
The error is:

ERROR: Timeout after 10 minutes
Error cloning remote repo 'origin'

Could you check please? I have no idea what this test does...
Thx

@ealdaz-seesai
Copy link
Contributor Author

Also not sure I understand the submodule point you were making, I haven't changed any submodule.

@julianoes
Copy link
Contributor

I'm really confused about the state of this PR, I can't get it merged properly either. It's odd.

Some submodules are wrong, see here:
Selection_048

Let me try to apply the diff and create one new clean commit.

@julianoes
Copy link
Contributor

I have the diff applied cleanly but I can't push it to your fork.

Could you make the checkmark as described here?
https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/allowing-changes-to-a-pull-request-branch-created-from-a-fork

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented May 5, 2020 via email

@julianoes
Copy link
Contributor

Is it because the repository is not my personal one but part of an organisation?

That's probably why. Do you want to create a new PR with the clean diff or should I do it?

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented May 6, 2020 via email

@ealdaz-seesai
Copy link
Contributor Author

OK, I've figured out what the issue was. Those submodules were added to my git branch 3 weeks ago and I didn't realize. I've removed them now. I'm hoping it should all be OK now.

@julianoes
Copy link
Contributor

Great, thanks @ealdaz-seesai.

@Jaeyoung-Lim could you please give this a review?

Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim 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 contribution and sorry for the late review.

Small comment regarding indentation changes

Would it be possible to squash the commits? Most of the commits seems to be merge commits or minor changes.

vehicle_attitude_s _vehicle_att{};
sensor_combined_s _sensor_combined{};
actuator_controls_s _act_controls{}; /**< direct control of actuators */
vehicle_attitude_s _vehicle_att{};
Copy link
Member

Choose a reason for hiding this comment

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

Please fix the indentation errors

Copy link
Contributor Author

@ealdaz-seesai ealdaz-seesai May 7, 2020

Choose a reason for hiding this comment

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

No problem for late review, everyone is very busy.
I'm just happy to be able to contribute.
Ha, pushing my very average git skills with this...never tried squashing commits before, I'll google and give it a try...

Hadn't noticed the indent changes, I had run the fix_code_style.sh and thought that took care of that sort of thing. But just realized that CLion was using tabs as spaces, will sort it out.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks!

@@ -113,15 +114,15 @@ class RoverPositionControl : public ModuleBase<RoverPositionControl>, public Mod

uORB::Subscription _parameter_update_sub{ORB_ID(parameter_update)};

manual_control_setpoint_s _manual{}; /**< r/c channel data */
manual_control_setpoint_s _manual{}; /**< r/c channel data */
Copy link
Member

Choose a reason for hiding this comment

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

unnecessary indentation changes

Copy link
Member

Choose a reason for hiding this comment

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

White spaces are still not addressed

sensor_combined_s _sensor_combined{};
actuator_controls_s _act_controls{}; /**< direct control of actuators */
vehicle_attitude_s _vehicle_att{};
sensor_combined_s _sensor_combined{};
Copy link
Member

Choose a reason for hiding this comment

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

same here

Copy link
Member

Choose a reason for hiding this comment

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

White spaces are still not addressed

@@ -406,7 +407,7 @@ RoverPositionControl::run()
bool manual_mode = _control_mode.flag_control_manual_enabled;

/* only run controller if position changed */
if (fds[0].revents & POLLIN) {
if (fds[0].revents & POLLIN || fds[4].revents & POLLIN) {
Copy link
Member

Choose a reason for hiding this comment

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

I think we can use just local_position (fds[4]) and remove fds[0]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is local position also available if only using GPS?

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented May 8, 2020

Hi @Jaeyoung-Lim , Ok so I've really tried (for 3 hours) I've rebased and squashed, but still all the commits appear. I tried rebasing again and then all sorts of conflicts happen, I think it's got to do probably with the fact that I've merged twice already in the last months. I'm not comfortable enough with git to understand what is really going on, and I'm afraid I can't really spend anymore time with this.
If it is really a big issue I could do a new PR...

Added local position as a valid source of position
@ealdaz-seesai
Copy link
Contributor Author

OK, so it was annoying me to leave it half done. So decided to give it one last go and rebase again and skip some commits and it has worked.
I've tested in SITL and all works as intended.

I did notice a new "feature" in this latest master and it's that SITL rover complains that no power is unavailable and doesn't let you arm. I had to disable power check flag. (CBRK_SUPPLY_CHECK).

Note that I couldn't reboot either from QGroundcontrol... i'm pretty sure I could before...
So a couple of things to add as a future PR...

pxh> WARN  [PreFlightCheck] system power unavailable

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented May 11, 2020

Jenkins SITL Tests fail, but not sure why... would any of you know ?
Doesn't seem to be in an area related to the files changed... as these SITL tests are done for the iris not rover ...

@julianoes
Copy link
Contributor

@Jaeyoung-Lim would be great if you could follow up.

@Jaeyoung-Lim
Copy link
Member

@julianoes Jenkins failure is not related to this PR. There are a few comments that are not addressed from @ealdaz-seesai Otherwise looks good to me

@julianoes
Copy link
Contributor

@Jaeyoung-Lim you're call if you want those addressed or merge anyway.

Copy link
Member

@Jaeyoung-Lim Jaeyoung-Lim left a comment

Choose a reason for hiding this comment

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

@julianoes Since this has been here for a while, I think it makes sense to merge. i will address the comments myself

@julianoes julianoes merged commit c96b524 into PX4:master May 13, 2020
@julianoes
Copy link
Contributor

Thanks @ealdaz-seesai !

@ealdaz-seesai
Copy link
Contributor Author

ealdaz-seesai commented May 13, 2020 via email

@RichardHopkirk RichardHopkirk deleted the rover-hold branch September 3, 2020 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants