Jaeyoung-Lim / px4-offboard

Example of PX4 offboard control over microdds using python ROS 2
BSD 3-Clause "New" or "Revised" License
120 stars 52 forks source link

is there any cpp example of the offboard control? #5

Open JetJie opened 1 year ago

JetJie commented 1 year ago

the offboard_control.cpp from /px4_ros_com/src/examples/offboard could not run well. Could you provide any other cpp offboard example? thank you.

Jaeyoung-Lim commented 1 year ago

@JetJie It shouldnt be too hard to create a cpp example, but could you explain what the problem is exactly?

JetJie commented 1 year ago

the problem is that my previous offboard node is in cpp(microRTPS version). But now it cannot run on the current micro XRCE-DDS version. So I need a cpp offboard example to run my node in the new XRCE-DDS environment.

Another issue is, there is no arm and mode change in your example. So could you tell me how to do that?

Ecuashungo commented 1 year ago

I have a working C++ node for a simulation environment (px4_sitl gazebo) that I can share. It was inspired by this repo. @Jaeyoung-Lim I can make a pull request, how would you like to structure the repo if c++ and python are mixed?

elanius commented 1 year ago

@Ecuashungo It would be great if you could provide a working C++ example. I have struggled with it for a few days, but my simulated iris drone is always on the ground. I opened the discussion here I think that problem is somewhere on the PX4 side because the drone is armed and switched to offboard mode. But TrajectorySetpoint is somehow ignored.

I am starting PX4 (tag v1.13.1) like this make px4_sitl_rtps gazebo I just modified ROMFS/px4fmu_common/init.d-posix/px4-rc.rtps where I had to start microdds_client instead of micrortps_client. microdds_client start -t udp -h 127.0.0.1 -p 8888

It would be great if you could share your PX4 setup.

JetJie commented 1 year ago

@Ecuashungo Thanks for sharing in advance and I am looking forward to your CPP example. If there is no progress here. I would like to back v1.13.1 with the rtps version. In rtps version, I also can send commands to Pixhawk 4 Autopilot to arm a real drone. I am afraid that with the new DDS version, there will be some new unknown issues when communicating with the Pixhawk 4 Autopilot.

Ecuashungo commented 1 year ago

I have created a pull request with a c++ example: #7

Ecuashungo commented 1 year ago

@elanius

I am starting PX4 (tag v1.13.1) like this make px4_sitl_rtps gazebo

I think this is wrong. You need the main branch for it to work with the new DDS system.

You can have a look at the new README.md, where I have written down everything step by step.

elanius commented 1 year ago

@Ecuashungo you are right, this was my issue. Finally, the drone did takeoff.

hwanyongpark commented 8 months ago

@Ecuashungo @Jaeyoung-Lim Hi thank you for python and cpp example of offboard control. I tried cpp offboard example node in ros2 humble & Gazebo Garden. I run just single drone on gazebo with make px4_sitl gz_x500 and run the code, the code runs smoothly. The problem is that I want to run two drones using the commands below link. https://docs.px4.io/main/en/sim_gazebo_gz/multi_vehicle_simulation.html I want to offboard control the first drone, so I changed the topic as shown in the picture below. Screenshot from 2024-01-18 20-37-26

However, even if I run the node, the drone does not work. Could you please help? These are the topics when i spawn the dr Screenshot from 2024-01-18 20-40-09 ones.

Jaeyoung-Lim commented 8 months ago

@hwanyongpark Please provide more details of "not working". How does it fail? Do you have any logs to show? Have you checked if whether you get any data out of each drone even before you run the offboard code?

hwanyongpark commented 8 months ago

Sorry for not being detailed. Let me elaborate on why the code doesn't work. When I run the code, it works fine, but it doesn't work because the commands aren't being delivered to the drone. Screenshot from 2024-01-18 21-07-37

As a result of checking the connection between nodes and topic transmission through rqt_graph, it appears that the connection between the publisher and subscriber is good.

Screenshot from 2024-01-18 21-07-15

Jaeyoung-Lim commented 8 months ago

@hwanyongpark I now see that you are using code as part of the PR? Please try manually arming the drone via QGC.

Unfortunately, I haven't tested the code, and it is not yet part of this repository