Go to the documentation of this file.00001
00002 import roslib;
00003 roslib.load_manifest('ardrone2control')
00004 import rospy
00005 import math
00006 import time
00007 import numpy as np
00008 import std_msgs.msg
00009 import sys
00010
00011 import tf
00012 from tf.transformations import euler_from_quaternion
00013
00014 from sensor_msgs.msg import Image, RegionOfInterest, CameraInfo
00015 from geometry_msgs.msg import Twist
00016 from geometry_msgs.msg import Wrench
00017 from sensor_msgs.msg import Range
00018
00019
00020 from visualization_msgs.msg import Marker
00021 from visualization_msgs.msg import MarkerArray
00022 from geometry_msgs.msg import Point
00023 from geometry_msgs.msg import Vector3
00024 from std_msgs.msg import ColorRGBA
00025 from geometry_msgs.msg import Quaternion
00026
00027 import random
00028
00029 disturbX = []
00030 disturbY = []
00031 disturbZ = []
00032
00033 with open('/home/trungnguyen/fuerte_workspace/TrackingController/ExternalDisturbance.txt') as f:
00034 for line in f:
00035 data = line.split()
00036 disturbX.append(float(data[0]))
00037 disturbY.append(float(data[1]))
00038 disturbZ.append(float(data[2]))
00039
00040
00041 def CirclePath(OriginX, OriginY, OriginZ, Radius, time):
00042 x = round(OriginX + Radius * math.cos(2.0 * time / 100.0 * 2 * math.pi- math.pi/2),5);
00043 y = round(OriginY + Radius * math.sin(2.0 * time / 100.0 * 2 * math.pi- math.pi/2),5);
00044
00045 return (x, y, OriginZ)
00046
00047
00048 if __name__ == '__main__':
00049 TimeStart = 0
00050 rospy.init_node("TestGeometricGCTrackingController")
00051 listener = tf.TransformListener()
00052
00053
00054 cmd_vel_publisher = rospy.Publisher('/cmd_vel', Twist)
00055 cmd_forcetorque_publisher = rospy.Publisher('/cmd_forcetorque', Wrench)
00056
00057
00058 guiding_vectors_publisher = rospy.Publisher('/guidingVectors', MarkerArray)
00059
00060 GoalTf = tf.TransformBroadcaster()
00061
00062 ith = 0
00063
00064 last_time = 0
00065 current_time = rospy.get_time()
00066 rate = rospy.Rate(50.0)
00067 while not rospy.is_shutdown():
00068
00069 current_time = rospy.get_time()
00070 dt = (current_time - last_time)
00071 last_time = current_time
00072
00073 XOrigin = 0
00074 YOrigin = 0
00075 ZOrigin = 0.7
00076 Radius = 1
00077
00078 if TimeStart == 0:
00079 TimeStart = current_time
00080 Time = current_time - TimeStart
00081
00082
00083 (Xref, Yref, Zref) = CirclePath(XOrigin, YOrigin, ZOrigin, Radius, Time)
00084
00085 if (Yref - YOrigin)>=0:
00086 YawGoalRotate = math.pi/2 + math.acos((Xref-XOrigin)/Radius)
00087 else:
00088 YawGoalRotate = math.pi/2 - math.acos((Xref-XOrigin)/Radius)
00089
00090
00091 GoalTf.sendTransform((Xref, Yref, Zref),tf.transformations.quaternion_from_euler(0.0,0.0, YawGoalRotate),rospy.Time.now(),"/goal","/world")
00092
00093
00094
00095 rate.sleep()
00096
00097
00098