Automatic flight using ROS failed

Hi, I tried to move the Erle Copter automatically, programming a ROS node that suscribes to mavros/setpoint_position/local topic and it was supossed to take off at 4 meters and then move 3 meter in the x axis. But it was a disaster (it crashed), I attach the log file of the flight in case you could look a it and you could find where the error is. I don’t know why it behaved that way, so maybe someone could help me with this.
18-04-28_10-05-40_1.bin (338.6 KB)

We are based in this tutorial: http://docs.erlerobotics.com/simulation/vehicles/erle_copter/tutorial_3 . In the DO STUFF section in the code, we added the following:

ros::Publisher local_pos_pub = n.advertise<geometry_msgs::PoseStamped>(“mavros/setpoint_position/local”,10);
geometry_msgs::PoseStamped pose;

pose.pose.position.x = 3;
pose.pose.position.y = 0;
pose.pose.position.z = 4;
ROS_INFO(“Move X”);

for(int i = 100; ros::ok() && i>0; --i){
local_pos_pub.publish(pose);
ros::spinOnce();
r.sleep();
}

sleep(10);

Is there anything we are doing wrong? Is this the best way to move the real ErleCopter (not simulated) automatically?
Thanks in advance.
Regards.

Please have a look at excellent work from @khancyr the wiki and on youtube ,
http://ardupilot.org/dev/docs/ros-sitl.html

Additionnal comment on experimenting with automatic flight
Make all test on simulator
Test , retest and TEST AGAIN !!

Make sure that you practice manual override with Radio Control while testing automatic modes

1 Like