<commit_before>#!/usr/bin/env python
import roslib; roslib.load_manifest('great-ardrones')
import rospy

from geometry_msgs.msg import Twist
from std_msgs.msg import Empty

import sys, select, termios, tty, time, numpy as np


def getKey():
    tty.setraw(sys.stdin.fileno())
    select.select([sys.stdin], [], [], 0)
    key = sys.stdin.read(1)
    termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
    return key


global velocityTStamp
velocityTStamp = ()
goal = np.array([0, 0, 0])
global oldLoc
oldLoc = np.array([1, 1, 1])

def callback(data):
    rospy.loginfo("Current Location %s",data.data)
    cur = np.array(data.data)
    if np.sum(np.abs(cur-oldLoc))==0:
    	land_pub.publish(Empty())
    	print "out of motion capture rig"
    else:
	   global oldLoc
	   oldLoc = cur
	   gamma = 0.1
	   velocities = (goal-cur)*gamma
	   bound = 0.5
	   velocities[velocities>bound] = bound
	   velocities[velocities<-bound] = -bound
	   global velocityTStamp
	   velocityTStamp = (velocities, time.clock())



print "1"
settings = termios.tcgetattr(sys.stdin)

pub = rospy.Publisher('cmd_vel', Twist)
land_pub = rospy.Publisher('/ardrone/land', Empty)
reset_pub = rospy.Publisher('/ardrone/reset', Empty)
takeoff_pub = rospy.Publisher('/ardrone/takeoff', Empty)

rospy.init_node('great-ardrones')
#rospy.Subscriber("/Drone/pose", String, callback)
print "2"

try:
    while(True):
        key = getKey()
        # takeoff and landing
        print key
        if key=="q":
            quit()
        if key == 'l':
            land_pub.publish(Empty())
        elif key == 't':
            takeoff_pub.publish(Empty())

        twist = Twist()
        if key=="g":
            key = getKey()
            cur = ""
            temp = []
            while key!="e":
                if key!="-" and not key.isdigit():
                    cur += key
                else:
                    temp.append(int(cur))
                    cur = ""
                key = getKey()
        	goal = np.array(temp)
        elif len(velocityTStamp)==2 and time.clock()-velocityTStamp[1]<1:
        	LINEAR.x, LINEAR.y, LINEAR.z = velocityTStamp[0]
        pub.publish(twist)

except Exception as e:
    try:
	print repr(e)
	print e
	land_pub.publish(Empty())
	twist = Twist()
	pub.publish(twist)
    finally:
        twist = Twist()
        pub.publish(twist)
        termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
<commit_msg>Somethign?<commit_after>#!/usr/bin/env python
import roslib; roslib.load_manifest('great-ardrones')
import rospy

from geometry_msgs.msg import Twist
from std_msgs.msg import Empty
from std_msgs.msg import String
import sys, select, termios, tty, time, numpy as np


def getKey():
    tty.setraw(sys.stdin.fileno())
    select.select([sys.stdin], [], [], 0)
    key = sys.stdin.read(1)
    termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)
    return key


global velocityTStamp
velocityTStamp = ()
goal = np.array([0, 0, 0])
global oldLoc
oldLoc = np.array([1, 1, 1])

def callback(data):
    rospy.loginfo("Current Location %s",data.data)
    cur = np.array(data.data)
    if np.sum(np.abs(cur-oldLoc))==0:
    	land_pub.publish(Empty())
    	print "out of motion capture rig"
    else:
	   global oldLoc
	   oldLoc = cur
	   gamma = 0.1
	   velocities = (goal-cur)*gamma
	   bound = 0.5
	   velocities[velocities>bound] = bound
	   velocities[velocities<-bound] = -bound
	   global velocityTStamp
	   velocityTStamp = (velocities, time.clock())



print "1"
settings = termios.tcgetattr(sys.stdin)

pub = rospy.Publisher('cmd_vel', Twist)
land_pub = rospy.Publisher('/ardrone/land', Empty)
reset_pub = rospy.Publisher('/ardrone/reset', Empty)
takeoff_pub = rospy.Publisher('/ardrone/takeoff', Empty)

rospy.init_node('great-ardrones')
rospy.Subscriber("vrpn_client_node/Drone/pose", String, callback)
print "2"

try:
    while(True):
        key = getKey()
        # takeoff and landing
        print key
        if key=="q":
            quit()
        if key == 'l':
            land_pub.publish(Empty())
        elif key == 't':
            takeoff_pub.publish(Empty())

        twist = Twist()
        if key=="g":
            key = getKey()
            cur = ""
            temp = []
            while key!="e":
                if key!="-" and not key.isdigit():
                    cur += key
                else:
                    temp.append(int(cur))
                    cur = ""
                key = getKey()
        	goal = np.array(temp)
        elif len(velocityTStamp)==2 and time.clock()-velocityTStamp[1]<1:
        	LINEAR.x, LINEAR.y, LINEAR.z = velocityTStamp[0]
        pub.publish(twist)

except Exception as e:
    try:
	print repr(e)
	print e
	land_pub.publish(Empty())
	twist = Twist()
	pub.publish(twist)
    finally:
        twist = Twist()
        pub.publish(twist)
        termios.tcsetattr(sys.stdin, termios.TCSADRAIN, settings)

{'fraction_non_alphanumeric': 0.13557594291539246, 'fraction_numerical': 0.007747196738022426, 'mean_word_length': 2.4235868806699234, 'pattern_counts': {'":': 6, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2101116', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1692, 'n_words': 364}