# VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program

Source: https://forum.modalai.com/topic/4237/voxl2-ros2-drone-runs-figure-8-offboard-program-instead-of-my-program
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2025-03-06 16:28:09 UTC by GlennTee
Replies: 24 · Views: 7169

## GlennTee · 2025-03-06 16:28:09 UTC

Hello,

I recently started working with a Starling drone with VOXL2 and ROS2, and I am having a bit of trouble trying to run a sample offboard program I found from the PX4 website. I followed the steps on the website to upload and run a program that allows the drone to send setpoints, enter offboard mode, arm, fly five meters into the air, and finally wait. However, when attempting to run the program, the default Figure 8 program on the drone runs instead. This is the link to the guide I followed: https://docs.px4.io/main/en/ros2/offboard_control.html

Additionally, I also ran the command **voxl-vision-hub** in the terminal with some of the outputted information shown below:

=================================================================
Parameters as loaded from config file:
config_file_version:        1

MAVROS / MAVSDK
en_localhost_mavlink_udp    0
localhost_udp_port_number:  14551

VIO
en_vio:                     1
vio_pipe:                   qvio
secondary_vio_pipe:         ov
en_reset_vio_if_initialized_inverted: 1
vio_warmup_s:               3.000000
send_odom_while_failed:     1

MISC FEATURES
horizon_cal_tolerance:      0.500000
OFFBOARD MODE
offboard_mode:              figure_eight
follow_tag_id:              0
figure_eight_move_home:     1
robot_radius:               0.300000
collision_sampling_dt:      0.100000
max_lookahead_distance:     1.000000
FIXED FRAME RELOCALIZATION
en_tag_fixed_frame:         0
fixed_frame_filter_len:     5
en_transform_mavlink_pos_setpoints_from_fixed_frame:0

It should be noted that the drone has Ubuntu 18.04 and ROS2 foxy. The PX4 and Mavlink services are also enabled and running. I'm wondering if there is a step I'm missing or some software that I am missing. Anything helps. Thank you.

## Reply by Eric Katzfey (ModalAI staff) · 2025-03-06 16:31:57 UTC

@GlennTee You will want to configure voxl-vision-hub to not send offboard commands if you are trying to use offboard commands from ROS2. Set `offboard_mode: off` in the configuration file `/etc/modalai/voxl-vision-hub.conf`.

## Reply by GlennTee · 2025-03-06 17:28:15 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Thank you, I will try that!

## Reply by GlennTee · 2025-03-06 18:56:29 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Hi again. I just tried flying it again and the drone did not default to running the Figure Eight program this time, but instead it did nothing once I swapped the controller to offboard mode. It did not arm, the props did not spin, or anything like that, but did absolutely nothing. I made sure to set "offboard_mode": "off" in voxl-vision-hub. I've attached a screenshot of my terminal below.
![image.png](https://forum.modalai.com/assets/uploads/files/1741287291401-image.png)

## Reply by Eric Katzfey (ModalAI staff) · 2025-03-06 20:03:06 UTC (in reply to GlennTee)

@GlennTee Okay, then probably some issue with connectivity between ROS2 and PX4. Doesn't seem like anything from ROS2 is getting to PX4. I'll ask some team members who have some experience with ROS2 what they think.

## Reply by teddy.zaremba · 2025-03-07 16:43:59 UTC (in reply to GlennTee)

@GlennTee So that example requires you have the MicroDDS installed and running to communicate with PX4 (guide [here](https://docs.modalai.com/ros2-installation-voxl2/#voxl2-microdds-communication-with-px4)). 

Alternatively, you can run offboard commands via mavsdk (example [here](https://github.com/mavlink/MAVSDK-Python/blob/main/examples/offboard_position_ned.py)). If you do it this way, make sure to edit that example to connect on port 14551 and set en_localhost_mavlink_udp to true in 'etc/modalai/voxl-vision-hub.conf'. 

Let me know if that helps.

## Reply by GlennTee · 2025-03-07 17:47:37 UTC (in reply to teddy.zaremba)

@teddy-zaremba Thank you. I installed MicroDDS and am running the agent in VOXL2. I just enabled it and made sure the necessary services are running, but it looks like I got the same result as before, where nothing would happen after supposedly the Arm command was sent. Is there anything else I could be missing?
![98455a09-c950-4002-9d21-54ebfdca9b97-image.png](https://forum.modalai.com/assets/uploads/files/1741369611419-98455a09-c950-4002-9d21-54ebfdca9b97-image.png) 

![d204ddfe-a2ed-4408-828b-b108eea09921-image.png](https://forum.modalai.com/assets/uploads/files/1741369655651-d204ddfe-a2ed-4408-828b-b108eea09921-image.png)

## Reply by teddy.zaremba · 2025-03-07 21:02:44 UTC (in reply to GlennTee)

@GlennTee What do you see when you run ros2 topic list?

Have you run "apt-get install voxl-ros2-foxy && apt-get install voxl-mpa-to-ros2" followed by "voxl-configure-mpa-to-ros2". 

[Similar issue that might be helpful](https://forum.modalai.com/topic/3953/setting-up-voxl2-microdds-communication-with-px4/8)

## Reply by GlennTee · 2025-03-11 18:15:41 UTC (in reply to teddy.zaremba)

@teddy-zaremba Sorry for the late reply, I've already run both of those commands in that order. This is what comes up when I run "ros2 topic list"

![29fc1cc7-f198-49e7-b54d-1a376ed01046-image.png](https://forum.modalai.com/assets/uploads/files/1741716912562-29fc1cc7-f198-49e7-b54d-1a376ed01046-image.png)

## Reply by Kessie · 2025-03-11 19:57:24 UTC (in reply to GlennTee)

@GlennTee the problem lies in a mismatch between the topics which you see using "ros2 topic list" and the publishers from the offboard_control node.

The ros2 node has publishers defined as follows:
```
	OffboardControl() : Node("offboard_control")
	{

		offboard_control_mode_publisher_ = this->create_publisher<OffboardControlMode>("/fmu/in/offboard_control_mode", 10);
		trajectory_setpoint_publisher_ = this->create_publisher<TrajectorySetpoint>("/fmu/in/trajectory_setpoint", 10);
		vehicle_command_publisher_ = this->create_publisher<VehicleCommand>("/fmu/in/vehicle_command", 10);
```

Do you know where you changed the prefix uav_4?
I can't remember where to configure it.

So, you can change the ROS2 code, rebuild and it should work. Or remove the uav_4 prefix

## Reply by GlennTee · 2025-03-13 14:43:55 UTC (in reply to Kessie)

@Kessie Thank you. I'm not sure where I changed the prefix, but I can try to find it.

## Reply by claw · 2025-03-17 12:57:42 UTC (in reply to GlennTee)

@Kessie The good news is that removing the prefix allows the px4 to see the messages and arm. Thank you! The bad news is that we weren't sure this would work so the drone wasn't in our flying lab and we had to physically grab it and disconnect the battery. 

We tried powering on the RC controller to push the kill switch, but even though it connected to the receiver, the drone didn't respond to any of the RC controls including the mode and motor disable switches. 

How do we operate in offboard mode while preserving the ability to take over manually? Would it have worked if we powered on the drone in manual or position hold and then switched to offboard? Do we launch our code before or after the mode change?

## Reply by Kessie · 2025-03-17 13:06:52 UTC (in reply to claw)

@claw You'll need to change the parameter COM_RC_OVERRIDE to also allow overriding offboard mode.

Reference link : https://docs.px4.io/main/en/advanced_config/parameter_reference.html#COM_RC_OVERRIDE

## Reply by claw · 2025-03-17 15:33:56 UTC (in reply to Kessie)

@Kessie Great. Thank you for your help.

## Reply by GlennTee · 2025-03-18 16:03:37 UTC (in reply to Kessie)

@Kessie Hi again, we just changed COM_RC_OVERRIDE to allow for overriding offboard mode and we were able to cut the motors while the drone was operating in offboard mode. We modified the PX4 ROS 2 Offboard Control Example code to only enable offboard mode and arm the drone, but we noticed that once the drone armed, it had a lot of throttle. I'm guessing there is a setting maybe in QGroundControl to modify the throttle somehow, or is there another way to fix this?

## Reply by GlennTee · 2025-03-18 19:19:44 UTC (in reply to GlennTee)

I just ran into another problem where I believe after running "voxl-configure-microdds" again, it seems some of my changes were reset as I noticed "offboard_mode" defaulted back to "figure_eight" while looking in the vision-hub config file. However, I did notice that my changes with the node publishers were not changed.
![9ede8047-26a7-4a41-8c04-bb7fcd35c104-image.png](https://forum.modalai.com/assets/uploads/files/1742325524847-9ede8047-26a7-4a41-8c04-bb7fcd35c104-image.png) 
I thought I have reverted everything to how it was before, but the drone is now back to not flying at all. I also noticed that my list of ros2 topics has also shrunk down as well. 
![bb2d4d6b-c60e-4e5a-bee8-66793f50ddc4-image.png](https://forum.modalai.com/assets/uploads/files/1742325319843-bb2d4d6b-c60e-4e5a-bee8-66793f50ddc4-image.png)

## Reply by teddy.zaremba · 2025-03-18 20:44:28 UTC (in reply to GlennTee)

@GlennTee said in [VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program](/post/21402):
> I thought I have reverted everything to how it was before, but the drone is now back to not flying at all. I also noticed that my list of ros2 topics has also shrunk down as well.
> 

This likely means that those topics got populated from the offboard script not the px4-ros bridge. Could you check that voxl-microdds-agent is running when you see this happen.

Check with "voxl-inspect-services"

![2f02cb49-ce93-4bb0-ad98-4163a961fa02-image.png](https://forum.modalai.com/assets/uploads/files/1742330607723-2f02cb49-ce93-4bb0-ad98-4163a961fa02-image.png)

## Reply by GlennTee · 2025-03-18 21:15:13 UTC (in reply to GlennTee)

@teddy-zaremba Hi, I just checked using that command and it appears the agent is enabled, but it is not running. 
![8a5d37ad-cb10-44da-9849-16d26502a287-image.png](https://forum.modalai.com/assets/uploads/files/1742332494785-8a5d37ad-cb10-44da-9849-16d26502a287-image.png)

## Reply by teddy.zaremba · 2025-03-18 22:13:25 UTC (in reply to GlennTee)

@GlennTee Can you run the command "voxl-microdds-agent" and share your output please?

## Reply by GlennTee · 2025-03-19 13:19:14 UTC (in reply to teddy.zaremba)

@teddy-zaremba said in [VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program](/post/21406):
> voxl-microdds-agent"

This is what I get:
![0ca1964f-a566-4197-b459-8f83fc26b790-image.png](https://forum.modalai.com/assets/uploads/files/1742390352226-0ca1964f-a566-4197-b459-8f83fc26b790-image.png)

## Reply by teddy.zaremba · 2025-03-19 14:33:48 UTC (in reply to GlennTee)

@GlennTee This looks fine to me if it's not running I'd suggest just restarting the service via "systemctl restart voxl-microdds-agent" and then double check that it's running with "voxl-inspect-services"

## Reply by claw · 2025-03-19 18:03:32 UTC (in reply to teddy.zaremba)

@teddy-zaremba Your help is very much appreciated.

Ok, so some of the confusion was related to editing the Python example, but it's actually running the cpp code. With that corrected, it shows all of the expected topics in the "ros2 topic list" and the code sends the arm command to the correct topic according to "ros2 topic echo /uav_4/fmu/in/vehicle_command", however, the Starling doesn't arm. We're trusting the example code as to the data structure that is actually populated and sent to that topic. Is there a reference as to what that should be?

## Reply by Zachary Lowell 0 · 2025-03-19 21:01:48 UTC

@claw said in [VOXL2/ROS2 Drone Runs Figure 8 Offboard Program Instead of My Program](/post/21417):
> Ok, so some of the confusion was related to editing the Python example, but it's actually running the cpp code. With that corrected, it shows all of the expected topics in the "ros2 topic list" and the code sends the arm command to the correct topic according to "ros2 topic echo /uav_4/fmu/in/vehicle_command", however, the Starling doesn't arm. We're trusting the example code as to the data structure that is actually populated and sent to that topic. Is there a reference as to what that should be?
> 
> Reply

@claw what code are you referring to? The ros2 figure 8 code is written in python:

https://gitlab.com/voxl-public/voxl-sdk/utilities/voxl-mpa-to-ros2/-/blob/master/colcon_ws/src/voxl_offboard_figure8/voxl_offboard_figure8/voxl_offboard_figure8.py?ref_type=heads

voxl-mpa-to-ros2 itself is written in CPP, but this node specific is in python as it can be either. With the DDS running, you do not need the voxl-mpa-to-ros2 code running as that just converts MPA to ros2, but regardless you dont need that running if the goal is just to publish to the dds via this ros2 node. How are you executing this? `ros2 run voxl_offboard_figure8 voxl_offboard_figure8`?

## Reply by GlennTee · 2025-03-20 14:29:45 UTC (in reply to Zachary Lowell 0)

@Zachary-Lowell-0 Hi, the code we are referring to is from an example on the PX4 website, where the drone should engage in offboard mode, arm, ascend a desired height, and wait. The link to that is here: https://docs.px4.io/main/en/ros2/offboard_control.html 

We are trying to run this program on our Starling drone, and the line we are running to execute the program is "ros2 run px4_ros_com offboard_control" 

With the changes made, we now see that the arm command is being sent to the correct topic, but the drone continues to not arm.

## Reply by GlennTee · 2025-03-20 16:19:02 UTC (in reply to GlennTee)

@GlennTee Good news! The program now runs, turns out I needed to add the .py extension to the file name when calling the run command, so it should be "ros2 run px4_ros_com offboard_control.py"

However, we experienced a lot of errors while running. The drone did arm (But only would do every even numbered attempt for some reason), however it did not fly. I'm working now to debug these errors. 
![image(1).png](https://forum.modalai.com/assets/uploads/files/1742487372952-image-1-resized.png)
