Robotics StackExchange | Archived questions

Send velocity commands over Mavros

I am using the Ardupilot SITL simulator to simulate my fixed wing aircraft. I want to control the velocity by sending velocity commands over Mavros:

ros::Publisher cmd_vel_pub = nh.advertise<geometry_msgs::TwistStamped>("mavros/setpoint_velocity/cmd_vel", 10); 

geometry_msgs::TwistStamped cmd_vel;

while (ros::ok()) {
    cmd_vel.header.stamp = ros::Time();
    cmd_vel.twist.linear.x = 10;
    cmd_vel.twist.angular.z = 10;
    cmd_vel_pub.publish(cmd_vel);
}

I have tried this in several flight modes, and I have tried to publish both before and after takeoff, but nothing happens. What is the correct way to send command velocities for a plane over Mavros?

Asked by Fredrika on 2018-04-17 11:38:52 UTC

Comments

Answers