how to use service to send data
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?
Asked by alienmonster on 2018-01-05 02:49:04 UTC
Comments
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.Asked by gvdhoorn on 2018-01-05 03:33:03 UTC
As to what the semantics are of the
PlutoPilot.srv
file, that is something you should ask the author of the package(s).Asked by gvdhoorn on 2018-01-05 03:33:53 UTC
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.
Asked by gvdhoorn on 2018-01-05 05:32:07 UTC