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

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

Open
JetJie opened this issue Nov 9, 2022 · 12 comments
Open

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

JetJie opened this issue Nov 9, 2022 · 12 comments

Comments

@JetJie
Copy link

JetJie commented Nov 9, 2022

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
Copy link
Owner

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

@JetJie
Copy link
Author

JetJie commented Nov 9, 2022

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
Copy link

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
Copy link

elanius commented Nov 17, 2022

@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
Copy link
Author

JetJie commented Nov 17, 2022

@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
Copy link

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

@Ecuashungo
Copy link

Ecuashungo commented Nov 18, 2022

@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
Copy link

elanius commented Nov 18, 2022

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

@hwanyongpark
Copy link

@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
Copy link
Owner

@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
Copy link

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
Copy link
Owner

@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

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