How to send velocity to pixhawk with Mavros?
Hi guys,
after searching a lot and don't get a solution I would like a help. I am a new user of Mavros package and I have some doubts about it. My setup for tests is:
1 Pixhawk with ArduCopter V3.2.1Quad firmware, 1 ESC 20A SkyWalker, 1 motor, 1 GPS+Compass, 1 radio receiver and 1 battery. I installed mavros on Indigo and ubuntu 14.04.
I want to start sending a simple command of linear velocity to pixhawk, for example vx = 1 m/s.
I typed the commands bellow in sequence:
1) sudo chmod 666 /dev/ttyACM0
2) roslaunch mavros px4.launch
3) rosrun mavros mavsafety arm
4) and my code: rosrun copter velocity
After that nothing happened. The the motor spun with default velocity of the node mavsafety arm and not with desired velocity.
What topic should I publish this message?
I checked the topic /mavros/setpoint_attitude/cmd_vel and the value that I set in the source code was there.
So, where is the mistake? Should I do some setup before to run?
I read at some forum people talking about some setup that we have to do...but is not clear for me.
Can anyone show a piece of code that make what I want or give me a tips?
Thank you!
I wrote a code trying to do this but without successful.
#include <ros/ros.h>
#include <std_msgs/String.h>
#include <stdio.h>
#include "geometry_msgs/TwistStamped.h"
#include "geometry_msgs/Vector3Stamped.h"
int main(int argc, char **argv)
{
ros::init(argc, argv, "comun");
ros::NodeHandle n;
ros::Publisher chatter_pub = n.advertise<geometry_msgs::TwistStamped>("/mavros/setpoint_attitude/cmd_vel",100);
ros::Rate loop_rate(10);
geometry_msgs::TwistStamped msg;
while(ros::ok()){
msg.header.stamp = ros::Time::now();
msg.header.seq=1;
msg.twist.linear.x = 1;
msg.twist.angular.x = 1;
chatter_pub.publish(msg);
ros::spinOnce();
loop_rate.sleep();
}
return 0;
}