Closed galadriel123 closed 7 years ago
Mavros is publisher, why you try publish your own waypoint to same topic and with incorrect message type?
Ugh. I apologise. I now figured out how to do it using the mavros/mission/push service. Here is the code for that
ros::NodeHandle n;
ros::ServiceClient client = n.serviceClient<mavros_msgs::WaypointPush>("mavr$
mavros_msgs::WaypointPush srv2;
ros::Rate loop_rate(100);
ros::spinOnce();
mavros_msgs::Waypoint msg;
msg.frame=mavros_msgs::Waypoint::FRAME_GLOBAL;
msg.command=1;
msg.is_current=true;
msg.autocontinue=true;
msg.param1=2.0;
msg.param2=3.0;
msg.param3=4.0;
msg.param4=5.0;
msg.x_lat=9.0;
msg.y_long =10.0;
msg.z_alt=2.0;
ros::spinOnce();
srv2.request.waypoints.push_back(msg);
if(client.call(srv2))
{
ROS_INFO("Success %d", srv2.response.success);
}
else
{
ROS_INFO("Failed");
}
The node runs successfully and gives output
[ INFO] [1496781027.254711560]: Success 0
But the waypoints do not update and the log shows me this error
[ INFO] [1496781662.707030726]: HP: requesting home position
[ INFO] [1496781672.707023923]: HP: requesting home position
[ INFO] [1496781682.707357223]: HP: requesting home position
[ INFO] [1496781692.706846724]: HP: requesting home position
[ INFO] [1496781702.707427939]: HP: requesting home position
[ INFO] [1496781712.706794993]: HP: requesting home position
[ERROR] [1496781717.008203992]: WP: upload failed: error #5
[ INFO] [1496781722.706693763]: HP: requesting home position
Thanks. I hope this is the right approach now?
Yes, but you don't have a connection. So push failed.
What do you mean by that? I am running roscore and the launch file.
Look at /diagnostics! Use rqt or rostopic echo -n1 /diagnostics
. FCU do not respond on home position request.
Also add roslaunch log. Note that roslaunch automatically start roscore.
@galadriel123 what is the state of this?
Closing as staled. @galadriel123 if the problem remains, reopen it.
I am pretty new to using mavros and I need to fly my ArduCopter in a straight line using ROS. I have written some code to publish one waypoint. Here it is,
It runs successfully without any errors, but the table shown by rosrun mavros mavwp show never gets updated. It always shows
Why is that? I tried arming it before running this node, but that didn't work either. Should I be publishing Waypointlist? but isn't that just an array of waypoints? I am pretty new to this. Please excuse any fundamental errors.