How to change VTOL Flight Mode from Multi-Rotor to Fixed Wing in OFFBOARD mode by using ROS (MAVROS) in Gazebo too without using QgroundControl? thank you

At ROS official website, it gives these information below (I have shared its links too).

mavros_msgs/CommandVtolTransition Service

http://wiki.ros.org/mavros_msgs
https://github.com/mavlink/mavros/blob/master/mavros_msgs/srv/CommandVtolTransition.srv

bool vtol_transition_cb (mavros_msgs::CommandVtolTransition::Request &req, mavros_msgs::CommandVtolTransition::Response &res)

ros::ServiceServer vtol_transition_srv

mavros::std_plugins::CommandPlugin Class Reference

When I tried to use the CommandVtolTransition from command.cpp, I had written like this according to this website:

https://github.com/mavlink/mavros/blob/master/mavros/src/plugins/command.cpp
Where it writes these:

vtol_transition_srv = cmd_nh.advertiseService(“vtol_transition”, &CommandPlugin::vtol_transition_cb, this);

ros::ServiceServer vtol_transition_srv;

And this for vtol_transition_cb function

bool vtol_transition_cb(mavros_msgs::CommandVtolTransition::Request &req,
			mavros_msgs::CommandVtolTransition::Response &res)
	{
		using mavlink::common::MAV_CMD;
		return send_command_long_and_wait(false,
			enum_value(MAV_CMD::DO_VTOL_TRANSITION), false,
			req.state,
			0, 0, 0, 0, 0, 0,
			res.success, res.result);
	}

Therefore, I had written like this below in my .cpp file:

mavros_msgs::CommandVtolTransition change_VTOL_flight;
ros::ServiceClient arming_client_VTOL;

arming_client_VTOL = controlnode.serviceClient<mavros_msgs::CommandVtolTransition>(“/mavros/cmd/command/vtol_transition”);

I had written my above code according to the @Jaeyoung-Lim ros website you had given me yesterday ([Writing a Simple Service and Client (C++)](https://Writing a Simple Service and Client (C++))) .

For the namespaces given for the VTOL in mavros is like this while they defined it there:

    vtol_transition_cb()
    bool mavros::std_plugins::CommandPlugin::vtol_transition_cb	(	mavros_msgs::CommandVtolTransition::Request & 	req,
    mavros_msgs::CommandVtolTransition::Response & 	res 
    )

Therefore, I am kind of confused a lot right now about what is the correct way to write this while my above the initial configuration seemed like it was good but it failed still.

I have never used “rqt” before, so is there any nice tutorial about how to control a px4 ros drone in gazebo from there?

According to given technical information I have found above that I shared in the thread, what is the best way to solve this problem or what is the cause of this problem? As I said before, I am really confused right now which there is no solid solution or any working example in the internet to verify where did I do wrong or correct. This, I will be very glad if you (@Jaeyoung-Lim) would give me some small hints to solve this problem please? Because I don’t know whom to ask, thank you very much for replying me with patient always @Jaeyoung-Lim friend, thank you.

1 Like