Robotics StackExchange | Archived questions

Trouble setting waypoints and running a mission using mavros

I am trying to create a set of waypoints, add them to a waypoint list and then fly a mission using rospy and MAVROS.

I could not find any python sample code. So, I tried to figure it out on my own. Unfortunately, I did not have much luck.

Here is the code I am using to create a waypoint and add it to the waypointlist.

    def create_waypoint(self):
        latitude = self.current_location.latitude
        longitude = self.current_location.longitude

        waypoint = Waypoint()
        waypoint.x_lat = latitude
        waypoint.y_long = longitude
        waypoint.autocontinue = True
        waypoint.is_current = False
        waypoint.frame = Waypoint.FRAME_GLOBAL
        waypoint.command = CommandCode.NAV_WAYPOINT

        self.waypoint_list._request_class.waypoints.push_back(waypoint)  

I get an error message saying "AttributeError: 'memberdescriptor' object has no attribute 'pushback'" when I do the push_back(waypoint)

This is how I am trying to start the mission after setting the waypoints:

    def start_waypoint_mission(self):
    rospy.wait_for_service('/mavros/mission/push')
    try:
        self.waypoint_push_srv.call(self.waypoint_list)
    except rospy.ServiceException, e:
        print "Service arm call failed: %s" % e

    rospy.wait_for_service('/mavros/set_mode')
    try:
        # https://github.com/mavlink/mavros/blob/master/mavros_msgs/srv/SetMode.srv
        self.drive_mode.call(220)
    except rospy.ServiceException, e:
        print "Service arm call failed: %s" % e

Questions:

Asked by Drkstr on 2019-05-02 09:19:34 UTC

Comments

Hey, i was doing a similar task. I want to know if you figured the correct way out ad if you can help me with it?

Asked by Mohit Singh on 2019-05-24 07:25:03 UTC

Answers