4 Copyright (c) 2016, Allgeyer Tobias, Aumann Florian, Borella Jocelyn, Hutmacher Robin, Karrenbauer Oliver, Marek Felix, Meissner Pascal, Trautmann Jeremias, Wittenbeck Valerij 8 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 10 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 12 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 14 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 16 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 import common.state_acquisition
as state_acquisition
27 from geometry_msgs.msg
import Pose, Point, Quaternion
28 from nav_msgs.msg
import OccupancyGrid
29 from asr_flir_ptu_driver.srv
import Range
30 from asr_robot_model_services.srv
import IsPositionAllowed
32 from common.evaluation_decorators
import *
44 return str(self.
pose) +
"\ntilt: " + str(self.
tilt)
48 smach.State.__init__(self, outcomes=[
'succeeded'],
49 output_keys=[
'goal_robot_pose',
'goal_ptu_position'])
57 rospy.loginfo(
'Init GENERATE_RANDOM_POSE')
60 rospy.Subscriber(
"map", OccupancyGrid, self.
mapCallback)
63 rospy.set_param(
"/nbv/speedFactorRecognizer", 0.5)
71 rospy.loginfo(
'Wait for callback from map')
76 self.
width = (data.info.width * data.info.resolution) / 2 + 0.5
77 self.
height = (data.info.height * data.info.resolution) / 2 + 0.5
78 rospy.loginfo(
'Random poses are generated between width: ' + str(-self.
width) +
' x ' + str(self.
width)
79 +
' and height: ' + str(-self.
height) +
' x ' + str(self.
height))
84 rospy.wait_for_service(
'/asr_flir_ptu_driver/get_range')
85 ptuRange = rospy.ServiceProxy(
'/asr_flir_ptu_driver/get_range', Range)()
88 rospy.loginfo(
'Random tilts are generated between tiltMin: ' + str(self.
tiltMin) +
' and tiltMax: ' + str(self.
tiltMax))
89 except (rospy.ServiceException, rospy.exceptions.ROSException), e:
95 fovx = rospy.get_param(
"/nbv/fovx")
98 fovy = rospy.get_param(
"/nbv/fovy")
107 rospy.loginfo(
'Executing GENERATE_RANDOM_POSE')
108 beginn = rospy.get_time()
114 random_robot_state.pose.position = Point(*[random.uniform(-self.
width, self.
width), random.uniform(-self.
height, self.
height), 0])
115 random_robot_state.pose.orientation = Quaternion(*tf.transformations.quaternion_from_euler(0, 0, random.uniform(0,359)))
116 random_robot_state.tilt = random.uniform(self.
tiltMin, self.
tiltMax)
124 userdata.goal_robot_pose = random_robot_state.pose
126 random_ptu_config = [0, random_robot_state.tilt]
127 userdata.goal_ptu_position = random_ptu_config
129 rospy.loginfo(
'Generated random\n' + str(random_robot_state.pose))
130 rospy.loginfo(
'Generated random PTU (tilt): ' + str(random_ptu_config))
146 if state_acquisition.approx_equal_robot_state(oldRobotState.pose, oldRobotState.tilt, robot_state_to_test.pose,
153 returns if robotPosition is allowed using the appropriate service call 155 rospy.wait_for_service(
'/asr_robot_model_services/IsPositionAllowed')
157 isReachableHandler = rospy.ServiceProxy(
'/asr_robot_model_services/IsPositionAllowed', IsPositionAllowed)
158 ret = isReachableHandler(robotPosition)
160 except (rospy.ServiceException, rospy.exceptions.ROSException), e:
161 rospy.logwarn(str(e))
def execute(self, userdata)
def isRobotPositionAllowed(self, robotPosition)
def checkCalculatedStateAllowed(self, robot_state_to_test)
AllowSameViewInRandomSearch
def mapCallback(self, data)