Unexpected topic ID on publishing CommanderState and VehicleCommand


Currently I am trying to switch the state of the px4 to offboard. I do so by activating the CommanderState receive: true in the uorb_rtps_message_idl.yaml. Then I use this script to publish the message over fastRTPS:

   auto timer_callback =	[this]()->void
    			if(i_setpoint_ < 100)
    				auto position_setpoint = px4_msgs::msg::PositionSetpoint();
    				position_setpoint.timestamp = timestamp_;
    				position_setpoint.x = 0.0;
    				position_setpoint.y = 0.0;
    				position_setpoint.z = 0.0;

				std::cout << "setpoint iteration: " << i_setpoint_ << std::endl;
				if (!switched_to_offboard)
					auto commander_state = px4_msgs::msg::CommanderState();
					commander_state.timestamp = timestamp_;
					commander_state.main_state = px4_msgs::msg::CommanderState::MAIN_STATE_OFFBOARD;
					std::cout << "Switched to offboard control mode." << std::endl;
					switched_to_offboard = true;
					std::cout << "nothing to do" << std::endl;

However the mavlink shell (sometimes) gives me the following warning:

nsh> WARN [micrortps_client] Unexpected topic ID

If I can listen to the message through ros2 topic echo, I see:

$ ros2 topic echo /CommanderState_PubSubTopic
timestamp: 0
main_state: 7

If I use the listener in the mavlink shell I get the following result:

nsh> listener commander_state

TOPIC: commander_state
timestamp: 1104099513 (0.225175 seconds ago)
main_state: 0

Could somebody please elaborate why the topic ID is unexpected (this doesn’t always happen, sometimes it doesn’t give any feedback at all) and why it is not reacting? Since MAVROS uses the same topic (commander_state for mode switching and vehicle_command for arming) I am unsure why the micrortps_client is rejecting the input of this topic. I have the same problem for arming the px4.


Did you solve this issue?

No. I heard they have to update the way to publish setpoints inside the uorb trees since currently it is not working as expected for me. There are some bugs in the setpoint triplet and eventually when those are fixed the system is still not listening to the setpoints given. I decided to use mavros instead and to give this another go in half a year.

@EdwinvanEmmerik in both sides of the bridge? You need to do that also on the Firmware side, otherwise you will get that unknown ID warning - check https://github.com/PX4/PX4-Autopilot/blob/master/msg/tools/uorb_rtps_message_ids.yaml.

Different subjects - MAVROS uses MAVLink, while with this bridge you directly communicate with uORB. Which also means you need to understand a bit better of how the internals of PX4 work (which in the other hand MAVROS already takes care of because it uses MAVLink). This is starting to be covered though - https://github.com/PX4/px4_ros_com/pull/62

1 Like