1 from general_ros
import *
2 from configuration
import *
3 from asr_msgs.msg
import AsrObject, AsrViewport
4 from asr_flir_ptu_controller.msg
import PTUMovementGoal, PTUMovementAction, PTUMovementActionResult
5 from move_base_msgs.msg
import MoveBaseGoal, MoveBaseAction, MoveBaseActionResult
6 from geometry_msgs.msg import (Pose, PoseWithCovariance, PoseWithCovarianceStamped)
7 from asr_robot_model_services.srv
import GetPose
8 from actionlib
import *
17 __builtin__.ptuPos = (0, 0)
20 if len(result.result.end_joint.position) == 2:
21 __builtin__.ptuPos = (result.result.end_joint.position[0], result.result.end_joint.position[1])
23 print(
"invalid ptu result")
24 rospy.Subscriber(
"/ptu_controller_actionlib/result", PTUMovementActionResult, ptuMoved)
27 __builtin__.basePos = (0, 0, 0)
29 thread = threading.Thread(target=getBasePos)
33 tfListener = tf.TransformListener()
35 tfListener.waitForTransform(
"/map",
"/base_link", rospy.Time(), rospy.Duration(4.0))
36 pos, quat = tfListener.lookupTransform(
"/map",
"/base_link", t)
37 orientationAngle = math.degrees(math.asin(quat[2]) * 2)
38 __builtin__.basePos = (pos[0], pos[1], orientationAngle)
39 rospy.Subscriber(
"/move_base/result", MoveBaseActionResult, baseMoved)
40 rospy.Subscriber(
"/initialpose", PoseWithCovarianceStamped, baseMoved)
43 set_base_client = rospy.Publisher(
"/initialpose", PoseWithCovarianceStamped, queue_size=1)
47 newPTUPos = (__builtin__.ptuPos[0] + pan, __builtin__.ptuPos[1] + tilt)
51 ptu_client = actionlib.SimpleActionClient(
"ptu_controller_actionlib", PTUMovementAction)
52 if not ptu_client.wait_for_server():
53 print(
"Could not connect to ptu action server")
54 ptu_goal = PTUMovementGoal()
55 ptu_goal.target_joint.header.seq = 0
56 ptu_goal.target_joint.name = [
"pan",
"tilt"]
57 ptu_goal.target_joint.velocity = [0, 0]
58 ptu_goal.target_joint.position = [float(pan), float(tilt)]
59 result = ptu_client.send_goal_and_wait(ptu_goal)
61 print(
"setPTU failed")
65 subprocess.call(
"python " + resources_for_active_scene_recognition_path +
"/src/getFrustum.py", shell=
True)
66 return ptu_client.get_result()
70 move_base_client = actionlib.SimpleActionClient(
"move_base", MoveBaseAction)
71 if not move_base_client.wait_for_server():
72 print(
"Could not connect to move base action server")
73 move_base_goal = MoveBaseGoal()
74 move_base_goal.target_pose.header.frame_id =
"/map" 75 move_base_goal.target_pose.pose.position.x = x
76 move_base_goal.target_pose.pose.position.y = y
77 move_base_goal.target_pose.pose.orientation.w = math.cos(math.radians(rotation) / 2.0)
78 move_base_goal.target_pose.pose.orientation.z = math.sin(math.radians(rotation) / 2.0)
79 result = move_base_client.send_goal_and_wait(move_base_goal)
81 print(
"moveBase failed")
82 return move_base_client.get_result()
85 set_base_goal = PoseWithCovarianceStamped()
86 set_base_goal.header.frame_id =
"map" 87 set_base_goal.pose.pose.position.x = float(x)
88 set_base_goal.pose.pose.position.y = float(y)
89 set_base_goal.pose.pose.orientation.w = math.cos(math.radians(float(rotation)) / 2.0)
90 set_base_goal.pose.pose.orientation.z = math.sin(math.radians(float(rotation)) / 2.0)
91 set_base_client.publish(set_base_goal)
94 setBase(*positionAndOrientation[0])
95 setPTU(*positionAndOrientation[1])
def moveBase(x, y, rotation)
def waitForService(serviceName, silence=False)
def setPositionAndOrientation(positionAndOrientation)
def setBase(x, y, rotation)