how to use service to send data

asked 2018-01-05 01:49:04 -0500

alienmonster gravatar image

updated 2018-01-05 03:27:46 -0500

I have a package of a drone https://github.com/simmubhangu/pluto_drone and I have to arm the drone and make it to take off. But I cant figure out how to use rosservice to move the drone and make the drone to take off. All the services are defined it the PlutoPilot.srv file.How can I use it to send data to the drone. The drone uses wifi to connect to the laptop.

my code is like this

#!/usr/bin/env python

from plutodrone.srv import *


import rospy

class send_data():

    def __init__(self):


        rospy.init_node('drone_board_data')
        self.resp1 = rospy.Service('PlutoService', PlutoPilot, self.arm)




        resp = PlutoPilotResponse()


    def arm(self,resp):
        resp = PlutoPilotResponse()
        resp.rcRoll = 1500
        resp.rcPitch = 1500
        resp.rcYaw = 1500
        resp.rcThrottle = 1000
        resp.rcAUX4 = 1500
        return resp

if __name__ == '__main__':
    while not rospy.is_shutdown():
        test = send_data()

        rospy.spin()

This code doesn't arm the drone. How does the code interact with the drone?

edit retag flag offensive close merge delete

Comments

1

Can you explain what you have problems with exactly? Invoking a service is a standard affair in ROS, in both C++ and Python (see wiki/Services fi). It should be no different with the pluto_drone packages.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-05 02:33:03 -0500 )edit
1

As to what the semantics are of the PlutoPilot.srv file, that is something you should ask the author of the package(s).

gvdhoorn gravatar image gvdhoorn  ( 2018-01-05 02:33:53 -0500 )edit
1

If I'm not mistaken, this is not a service client, but a server. The drone pkgs already implement the server, you need to write a client.

See Writing a Simple Service and Client (Python) for some guidance.

gvdhoorn gravatar image gvdhoorn  ( 2018-01-05 04:32:07 -0500 )edit