"mavlink msg set position target global int" is not working in HITL mode

Anyone know how to use position_target together with simulation? When I try and send mavlink_msg_set_position_target_global_int_t it does nothing. So looking at the PX4 code it seems I want to enable the follow_target object in the Navigator which happens when nav_state is changed to NAVIGATION_STATE_AUTO_FOLLOW_TARGET, so I see Commander does that when I send MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_FOLLOW_TARGET but when I do this jMavSim (in HITL mode) drops out of the sky and crashes, saying that the set mode command caused a disarm. Any thoughts?

I’m looking for fine grained velocity control (vx,vy,vz) and mavlink_msg_set_position_target_global_int_t seems to be it…

How are you changing the mode? It sounds like you also need to set MAV_MODE_FLAG_SAFETY_ARMED in the mode field, but it’s not clear how you’re requesting the change. Take a look at MAV_MODE_FLAG in the mavlink spec. http://mavlink.org/messages/common

Ah, I see now. The flags are absolute, not additive, ok, thanks, that fixed it.

Hey I am a complete beginner in this stuff. Please help me on how to send these commands MAV_MODE_FLAG_CUSTOM_MODE_ENABLED, PX4_CUSTOM_MAIN_MODE_AUTO, PX4_CUSTOM_SUB_MODE_AUTO_FOLLOW_TARGET
Is it through mavros or is there any PX4 msg . Currently I am publishing mavros/setpoint_raw/global in 10 hz but nothing is happening in simulation
Here is the echo of mavros/setpoint_raw/global ros2 topic
ros2 topic echo mavros/setpoint_raw/global
header:
stamp:
sec: 0
nanosec: 0
frame_id: ‘’
coordinate_frame: 5
type_mask: 3576
latitude: 49.0
longitude: 9.0
altitude: 510.0
velocity:
x: 0.0
y: 0.0
z: 0.0
ros2 topic info /mavros/setpoint_raw/global
Type: mavros_msgs/msg/GlobalPositionTarget
Publisher count: 1
Subscription count: 1