基于英尺距离的Ardrone运动校准

时间:2017-03-05 17:34:41

标签: ros ar.drone

很久以前我一直在研究ARDrone。有没有办法根据脚测量自动化无人机?

让我们说我必须在离地面仅6英尺的地方驾驶无人机。我怎样才能做到这一点 ? 我确实有一些rostopics。如何使用它们只用于6英尺的无人机飞行?

#flyup
rostopic :  /cmd_vel geometry_msgs/Twist '{linear:  {x: 0.0, y: 0.0, z: 1.0}, angular: {x: 0.0,y: 0.0,z: 0.0}}'

我在这里使用循环来实现相同的动作几次。如何使用rostopics将其校准到6英尺?

请检查代码。

#!/usr/bin/env python 

#import library ros 
import rospy 
import time


from geometry_msgs.msg import Twist
from std_msgs.msg import String 
from std_msgs.msg import Empty 
from ardrone_autonomy.msg import Navdata


#import class status untuk menentukan status ddari quadcopter
#from drone_status import DroneStatus  `    1`  


#COMMAND_PERIOD = 1000


class AutonomousFlight():
    def __init__(self):
        self.status = ""
        rospy.init_node('forward', anonymous=False)
        self.rate = rospy.Rate(1)
        self.pubTakeoff = rospy.Publisher("ardrone/takeoff",Empty, queue_size=10)
        self.pubLand = rospy.Publisher("ardrone/land",Empty, queue_size=10)
        self.pubCommand = rospy.Publisher('cmd_vel',Twist, queue_size=10)
        self.command = Twist()
        #self.commandTimer = rospy.Timer(rospy.Duration(COMMAND_PERIOD/1000.0),self.SendCommand)
        self.state_change_time = rospy.Time.now()    
        rospy.on_shutdown(self.SendLand)

    def TakeOff(self):
        self.pubTakeoff.publish(Empty()) 
        self.rate.sleep()


    def SendLand(self):
        self.pubLand.publish(Empty())    

    def SetCommand(self, linear_x, linear_y, linear_z, angular_x, angular_y, angular_z):
        self.command.linear.x = linear_x
        self.command.linear.y = linear_y
        self.command.linear.z = linear_z
        self.command.angular.x = angular_x
        self.command.angular.y = angular_y
        self.command.angular.z = angular_z
        self.pubCommand.publish(self.command)
        self.rate.sleep()

if __name__ == '__main__': 
    try: 
        i = 0
        distance = 0 
        uav = AutonomousFlight()

        while not rospy.is_shutdown():
            uav.TakeOff()
            if i <=3 :
                uav.SetCommand(0,0,1,0,0,0)
                i+=1
            elif i<=4:
                uav.SetCommand(0,0,0,0,0,0)
                i+=1

            else:
                break
        uav.SendLand()
    except rospy.ROSInterruptException:
       pass

从上面的代码中,无人机刚刚起飞并飞到6英尺......我怎么能这样做?

此致 卡锡尔

0 个答案:

没有答案