cli_controll.py
Go to the documentation of this file.
00001 import rospy
00002 import smach
00003 import smach_ros
00004 import types
00005 import tf
00006 import math
00007 import sys, getopt
00008 import subprocess
00009 
00010 from actionlib import *
00011 from actionlib.msg import *
00012 from geometry_msgs.msg import Pose, PoseWithCovarianceStamped, Point, Quaternion, Twist
00013 from asr_flir_ptu_controller.msg import PTUMovementGoal, PTUMovementAction
00014 
00015 
00016 def main(argv):
00017     rospy.init_node("ptu_manual_controller_script")
00018 
00019     rospy.loginfo('Trying to communicate with ptu via action msg.')
00020     client = actionlib.SimpleActionClient('ptu_controller_actionlib', 
00021                                           PTUMovementAction)
00022     if not client.wait_for_server(rospy.Duration.from_sec(10)):
00023         rospy.logwarn("Could not connect to ptu action server")
00024         return 'aborted'
00025       
00026     #path to visualization script, which is called after each ptu_movement
00027 
00028     visualization_script = ''
00029     try:
00030       opts, args = getopt.getopt(argv,"v:",["visualization="])
00031       for opt, arg in opts:
00032         if opt in ("-v", "--visualization"):
00033           visualization_script = arg
00034           print 'Using ' + visualization_script + ' for visualization.'
00035     except getopt.GetoptError:
00036       print 'No visualization script specified.'
00037 
00038     while True:
00039         pan = float(raw_input("Pan? "))
00040         tilt = float(raw_input("Tilt? "))
00041         ptu_goal = PTUMovementGoal()
00042         ptu_goal.target_joint.header.seq = 0
00043         ptu_goal.target_joint.name = ['pan', 'tilt']
00044         ptu_goal.target_joint.velocity = [0, 0]
00045         ptu_goal.target_joint.position = [pan, tilt] 
00046         client.send_goal(ptu_goal)
00047         if visualization_script != '':
00048           subprocess.call(" python " + visualization_script + " 1", shell=True)
00049 
00050     rospy.spin()
00051 
00052 if __name__ == '__main__':
00053     try:
00054          main(sys.argv[1:])
00055     except rospy.ROSInterruptException: pass
00056     


asr_flir_ptu_controller
Author(s): Ralph Schleicher, Patrick Schlosser
autogenerated on Thu Jun 6 2019 21:24:15