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

px4-ros2 offboard control with pyrhon example #1675

Open
JinraeKim opened this issue Nov 28, 2021 · 10 comments
Open

px4-ros2 offboard control with pyrhon example #1675

JinraeKim opened this issue Nov 28, 2021 · 10 comments

Comments

@JinraeKim
Copy link

There is a cpp script for offboard control example, but it would be also helpful to provide some launchable python codes for the same example as ros2 usually supports both languages.

@TSC21
Copy link
Member

TSC21 commented Nov 28, 2021

There is a cpp script for offboard control example, but it would be also helpful to provide some launchable python codes for the same example as ros2 usually supports both languages.

@JinraeKim thanks for the suggestion. We are open for contributions in this regard from anyone willing to do them. Are you open to contribute in this regard? Thank you

@JinraeKim
Copy link
Author

JinraeKim commented Nov 28, 2021

@JinraeKim thanks for the suggestion. We are open for contributions in this regard from anyone willing to do them. Are you open to contribute in this regard? Thank you

Thank you for your reply.
I'd like to do so, but I have been trying to learn how to use PX4 and ROS2; due to lack of my knowledge of both PX4 and ROS2 (and C++ as well), I don't think I can add an appropriate example. I'm really sorry.
If I find a successful example (but it could be a far future), I'll contribute.

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Nov 28, 2021

@JinraeKim Could you maybe elaborate if there is a specific reason you are trying to use python for offboard control?

@hamishwillee
Copy link
Collaborator

I would guess the same reason everyone uses Python when they are starting - it's a much easier language to learn.

@Jaeyoung-Lim
Copy link
Member

Jaeyoung-Lim commented Nov 28, 2021

@hamishwillee I totally agree, but more wondering if we should enable beginners use ROS2 + offboard.

Since the use case of ROS2 with PX4 is motivated by removing the performance bottlenecks coming from using mavlink, I was trying to understand why one would use python ROS2 with PX4.

IMO, it is safer to use mavsdk-python if the developer is starting out and does not understand what is going on inside PX4.

@hamishwillee
Copy link
Collaborator

@Jaeyoung-Lim Howdy! My take on this is that this is a matter of setting expectation - what can you do with each framework and programming language? What is easier for what task? What are the limits? There is no point telling a beginner "go and use MAVSDK" if that isn't going to get the performance they need for the task at hand.

Some questions

  • is there "really" a bottleneck using Python with ROS2 and offboard - note, I did not say "MAVLink"?
  • Is Python a reasonable peer of C++ in ROS.
  • Where do you think the boundaries are?

If the answer is "Python is a peer of C++ for ROS" then we should try have an example of that too. And here we should compare and contrast, with some kind of useful comparison of the options.

Can you give me some idea of where the border for usage is? Normally we say:

  • "MAVSDK has small learning curve, is intuitive, and is already customised for UAV domain". Use it where you can, which tends to be any kind of basic basic flight tasks - setting positions, taking off, landing, setting missions.
  • ROS is generic robotics. As such it has harder learning curve but it comes with a lot of useful routines for doing common stuff, and integrates well with computer vision libraries which would be hard to write yourself. So if you want to leverage existing code that would be hard to write yourself this is worth considering.
    • Sounds like you're adding performance as a benefit here, presumably because of the ROS2 integration with uorb?

@JinraeKim
Copy link
Author

@JinraeKim Could you maybe elaborate if there is a specific reason you are trying to use python for offboard control?

It is because I'm familiar with Python and ROS2, not with C++ (main language is Julia though).

Honestly, there are too many choices to use PX4 so I'm not sure my plan is suitable for my research.
Also, I saw in docs that the developers highly recommend that I start with ROS2 for offboard control.

@JinraeKim
Copy link
Author

JinraeKim commented Nov 28, 2021

@Jaeyoung-Lim Howdy! My take on this is that this is a matter of setting expectation - what can you do with each framework and programming language? What is easier for what task? What are the limits? There is no point telling a beginner "go and use MAVSDK" if that isn't going to get the performance they need for the task at hand.

Some questions

  • is there "really" a bottleneck using Python with ROS2 and offboard - note, I did not say "MAVLink"?
  • Is Python a reasonable peer of C++ in ROS.
  • Where do you think the boundaries are?

If the answer is "Python is a peer of C++ for ROS" then we should try have an example of that too. And here we should compare and contrast, with some kind of useful comparison of the options.

Can you give me some idea of where the border for usage is? Normally we say:

  • "MAVSDK has small learning curve, is intuitive, and is already customised for UAV domain". Use it where you can, which tends to be any kind of basic basic flight tasks - setting positions, taking off, landing, setting missions.
  • ROS is generic robotics. As such it has harder learning curve but it comes with a lot of useful routines for doing common stuff, and integrates well with computer vision libraries which would be hard to write yourself. So if you want to leverage existing code that would be hard to write yourself this is worth considering.
    • Sounds like you're adding performance as a benefit here, presumably because of the ROS2 integration with uorb?

A nice summary!
As a beginner of PX4, there are too many routines to perform flight control tasks, although there are less comparisons between them.
IMO, there should be more comparisons between those approaches in terms of 1) performance, 2) usage pattern, and 3) how easy to learn and Implement.

@hamishwillee
Copy link
Collaborator

Also, I saw in docs that the developers highly recommend that I start with ROS2 for offboard control.

As above, you need to start with "what you want to achieve" and that will determine the path you take.

I have tried to integrate above summary in #1681 . I personally don't propose to create any Python ROS examples - though if someone wants to that would be great. I consider it a minor bug that we don't.

@haotianh9
Copy link

@JinraeKim I have tried to write a python version of offboard control, and it behaves the same as the original C++ version.
It is located in the scripts folder and can be ran by
python3 offboard_control_py.py
I've already submitted pull request .

natesimon added a commit to irom-princeton/px4_ros_com that referenced this issue Mar 8, 2022
…ranch in our fork for python-based offboard mode
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

5 participants