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

Nice Project! I have some questions. #1

Open
Pinking-Lee opened this issue Oct 28, 2024 · 7 comments
Open

Nice Project! I have some questions. #1

Pinking-Lee opened this issue Oct 28, 2024 · 7 comments

Comments

@Pinking-Lee
Copy link

Pinking-Lee commented Oct 28, 2024

Thanks for your project. What a Nice Project!

I am currently working on the offboard control of VTOL by ROS2, too. But I am using C++ code, not python. This source code may inspire me a lot.

  1. I am a beginner of PX4. At start, I follow the official doc and achieve the offboard control to fly a square path in STIL simulation by px4_msgs::msg::TrajectorySetpoint msg. I can successfully changed the mode of VTOL to FW(Fixedwing) by px4_msgs::msg::VehicleCommand msg in ROS2. But then the plane can not fly the right path.
    May be the VTOL can not be offboard controlled by new uXRCE-DDS way(i.e., using official px4_msgs, it is very convenient)?

  2. Then I git your code and successfully run the demo. It is excellent! Here I have some questions:
    I mean, I am using current official PX4-Autopilot.git, V1.15. Have you customized a lot on PX4-Autopilot.git?
    Or I just only need to customize uXRCE DDS Agent and then I can achieve path following using C++?

  3. And some of your README.md has misspelling, i.e. [resrouces] should be fixed as [resources].

Thank you very much.

@JacopoPan
Copy link
Owner

JacopoPan commented Oct 29, 2024

Hi @Pinking-Lee

For point 1, In principle, off board control with uXRCE-DDS works fine in C++ and Python. This repo includes and example of rates control that at these lines

elif request.names[0] == 'roll':
self.roll_request = True
maneuver_time = 1.0
while self.roll_request:
current_time_ms = self.clock.now().nanoseconds / 1e6
if self.time_of_offboard_start_ms is None:
self.time_of_offboard_start_ms = current_time_ms
if (current_time_ms < (self.time_of_offboard_start_ms + maneuver_time*1e3)):
self.do_offboard(off_type='rat', roll=4.0, thrust=0.5) # aileron roll
self.aircraft_state = State.OFFBOARD
else:
des_lat, des_lon = self.get_coord_from_cart(x_offset=-1000.0, y_offset=300.0)
self.do_reposition(lat=des_lat, lon=des_lon, alt=200.0)
self.change_aircraft_state(State.FW)
self.time_of_offboard_start_ms = None
self.roll_request = False

For point 2, the only changes I made to PX4 1.14 are these 2 commits:

  • JacopoPan/PX4-Autopilot@ea133cb simply porting a fix for using Gazebo Harmonic (already in 1.15)
  • JacopoPan/PX4-Autopilot@dc003e9 a custom fix to use VehicleCommand to set the VTOL takeoff heading (it should be easy to apply it to 1.15 as well, if you want, or you can disregard if you don't care about the specific heading of the transition)

For point 3, thank you, I fixed it, if you see any other mistake please let me know. All the code you see here should be easy to re-write in C++ (in fact, I mostly work in C++ for this, but Python is friendlier for easy-to-run examples)

@JacopoPan
Copy link
Owner

note that I updated the dds_topics.yaml, it would have prevented doing rolls before but now it will work as in the README gif

@Pinking-Lee
Copy link
Author

Thanks. Refer to your example, I have reproduced the several basic functions and follow your example to control VTOL by C++.

Now I am working on the smooth trajectory tracking control of FW mode.
I find 2 msgs in px4_msgs as VehicleTrajectoryWaypoint.msg and VehicleTrajectoryBezier.msg.

I searched some comments, said they are mainly used for Mulitrotors.
And I currently haven't found any trajectory tracking control example scheme for FW mode by these 2 msgs yet (Maybe.., not support FW plane?).
Have you tried these 2 msgs to achieve smooth trajectory tracking in FW mode?
Do I need to independently write a set of tracking control code based on the attitude control case you provided?
Or give me some suggestions.

Thanks very much.

@JacopoPan
Copy link
Owner

You can definitely use off-board and the TrajectorySetpoint message with fixed-wings (see this example for the messages definitions https://github.com/PX4/px4_ros_com/blob/main/src/examples/offboard/offboard_control.cpp) but of course the modules in the fixed-wing position controller (L1, TECS) may or may not be able to follow with depending on its dynamic feasibility.

@Pinking-Lee
Copy link
Author

You can definitely use off-board and the TrajectorySetpoint message with fixed-wings (see this example for the messages definitions https://github.com/PX4/px4_ros_com/blob/main/src/examples/offboard/offboard_control.cpp) but of course the modules in the fixed-wing position controller (L1, TECS) may or may not be able to follow with depending on its dynamic feasibility.

yes... I tried, not follow with the FW dynamics. I am tring to find another way....

@JacopoPan
Copy link
Owner

It should work, make sure you publish the proper boolean flag for the position reference in the OffboardMode message.
And try very shallow turn, the banking limits are still set but some of the autopilot parameters.

@JacopoPan
Copy link
Owner

I just pushed an example that use the velocity field of TrajectorySetpoint

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

2 participants