About using Mavros to flytsim


I already follow the mavros api and use that in my code on roscpp flybase but why flytsim doesn’t respons my code command about override RC( i send 1700 throttle value)?

this is my code

#include <ros/ros.h>
#include <core_api/ParamGetGlobalNamespace.h>
#include <core_api/TakeOff.h>
#include <core_api/Land.h>
#include <core_api/PositionSet.h>
#include <mavros_msgs/OverrideRCIn.h>
#include <mavros_msgs/State.h>
#include <unistd.h>

#include <core_api/Arm.h>
std::string global_namespace;
ros::Subscriber mavros_state_sub;
#include <stdio.h>
#include <stdint.h>
#include <unistd.h>

ros::Publisher pub;

core_api::ParamGetGlobalNamespace namespace_srv;
core_api::TakeOff takeoff_srv;
core_api::Land land_srv;
core_api::PositionSet pos_srv;
core_api::Arm srv;
ros::ServiceClient pos_client,land_client,takeoff_client;

using namespace std;

int main(int argc, char **argv)
ros::init(argc, argv, “roscpp_demoapp1”);
ros::NodeHandle nh;

ros::ServiceClient namespace_client = nh.serviceClient<core_api::ParamGetGlobalNamespace>("/get_global_namespace");
global_namespace = namespace_srv.response.param_info.param_value;

  mavros_msgs::OverrideRCIn msg;
	ros::Publisher pub; 
	  pub = nh.advertise<mavros_msgs::OverrideRCIn>("/mavros/rc/override", 10);

 for(int i =1 ;i<=500000;i++){
	msg.channels[0] = 1500;     //Roll
    msg.channels[1] = 1500;    //Pitch
    msg.channels[2] = 1700;   //Throttle
    msg.channels[3] = 1500;        //Yaw
    msg.channels[4] = 0;
    msg.channels[5] = 0;
    msg.channels[6] = 0;
    msg.channels[7] = 0;
      ROS_INFO("SEND RC");

return 0;

please tell me how to make flytsim respon my code hehehe thankyouu…



Change “/mavros/rc/override” to “/”+global_namespace+"/mavros/rc/override".
But can you please explain why are you using RC override?


thankyou for your response, now the messages is detected by cmd BUT there is no respon from flytsim such as i send rc throttle 1700 but there is no respon, can you tell me why ???

i using override because i want to integrate with opencv to make image subcriber and my drone will at the center of the shape at the land


Why did you choose to not use simpler position or velocity setpoint API?

You have to change vehicle mode to RC mode. Are you familiar with PX4, sending rc override is something which is not recommend, specially for a multicopter. Please use position or velocity setpoint API for your task.


i have a few question

1.how to change from vehicle mode to rc mode ?? can you tell me ?
2. Why is not recommended to override Rc?

i already use that but after showing to my superviser , my superviser say that he didn’t recommend that way cause the move is not good as RC, and hard to Impllement PID concept, and i will use send rc(channel 4,5,6,7) cause i wanna grab something after i send that at my drone

Thankyou again for your respons



You can use QGC gui to change the vehicle mode. Open QGC, connect to the drone, click on current mode at the top bar, and it would show a drop down from which you can select your mode.

It is not recommended to override RC specially for multi-rotors as there controllers are wquite complicated, and you would have to write your own controllers, instead of using already furnished controllers of APM/PX4.

I am confused. Please explain it further, about what your supervisor suggested.



So basically my program using PID to make my drone on the center of the shape like rectangle. But hard to implement PID concept to velocity but more easier if RC, thats my supervisor said. and my drone have other purpose[ to take something(iron) from somewhere( i use magnet), but i confuse if i dont use rc as command to take that thing with magnet.

thank you for your respons



I am sorry but I don’t totally agree with that. Why do you think using RC is much easier that sending velocity commands? Moreover, which RC mode would you keep the vehicle at?


1.sorry, there is many rc mode ?
2.how to connect qgc to flytsim ??
3.is RC mode is the same as like API|Hold ? Are API hold is same as offboard mode ?
yeah i hope i use velocity but my superviser wants me to use RC override.



I think you should ask APM/PX4 forums to get more better idea, on what should be best for you.


Check here if you are using APM, else here if using PX4.


I tried to use qgc and connected, i change the mode to Manual and arming, but still no effect to the flytsim drone just do nothing, sorry i still confused about this :frowning:


You have to explain more.
Post your code here.
Along with all the steps that you have followed in detail.
What are your expectations from your code, and preferably attach a video.
Also, check for any errors any flytconsole’s message window at the right side.