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. 28 from lxml
import etree
30 from geometry_msgs.msg
import Pose, Point, Quaternion
31 import common.state_acquisition
as state_acquisition
32 from common.evaluation_decorators
import *
36 Please enter some comments here! 42 outcomes=[
'succeeded',
'aborted'],
43 input_keys=[
'goal_camera_pose',
46 'deactivated_object_normals_count'])
51 rospy.loginfo(
'Init STATE_RECORDING')
61 <position x="%(goal_camera_pose.position.x)s" y="%(goal_camera_pose.position.y)s" z="%(goal_camera_pose.position.z)s"/> 62 <orientation x="%(goal_camera_pose.orientation.x)s" y="%(goal_camera_pose.orientation.y)s" z="%(goal_camera_pose.orientation.z)s" w="%(goal_camera_pose.orientation.w)s" /> 65 <position x="%(goal_robot_pose.position.x)s" y="%(goal_robot_pose.position.y)s" z="%(goal_robot_pose.position.z)s"/> 66 <orientation x="%(goal_robot_pose.orientation.x)s" y="%(goal_robot_pose.orientation.y)s" z="%(goal_robot_pose.orientation.z)s" w="%(goal_robot_pose.orientation.w)s" /> 68 <goal_ptu_position pan="%(goal_ptu_position.pan)s" tilt="%(goal_ptu_position.tilt)s" /> 69 <deactivated_object_normals_count count="%(deactivated_object_normals_count)s" /> 77 rospy.loginfo(
'Executing STATE_RECORDING')
82 data = {
'goal_camera_pose.position.x':str(userdata.goal_camera_pose.position.x),
83 'goal_camera_pose.position.y':str(userdata.goal_camera_pose.position.y),
84 'goal_camera_pose.position.z':str(userdata.goal_camera_pose.position.z),
85 'goal_camera_pose.orientation.x':str(userdata.goal_camera_pose.orientation.x),
86 'goal_camera_pose.orientation.y':str(userdata.goal_camera_pose.orientation.y),
87 'goal_camera_pose.orientation.z':str(userdata.goal_camera_pose.orientation.z),
88 'goal_camera_pose.orientation.w':str(userdata.goal_camera_pose.orientation.w),
89 'goal_robot_pose.position.x':str(userdata.goal_robot_pose.position.x),
90 'goal_robot_pose.position.y':str(userdata.goal_robot_pose.position.y),
91 'goal_robot_pose.position.z':str(userdata.goal_robot_pose.position.z),
92 'goal_robot_pose.orientation.x':str(userdata.goal_robot_pose.orientation.x),
93 'goal_robot_pose.orientation.y':str(userdata.goal_robot_pose.orientation.y),
94 'goal_robot_pose.orientation.z':str(userdata.goal_robot_pose.orientation.z),
95 'goal_robot_pose.orientation.w':str(userdata.goal_robot_pose.orientation.w),
96 'goal_ptu_position.pan':str(userdata.goal_ptu_position[0]),
97 'goal_ptu_position.tilt':str(userdata.goal_ptu_position[1]),
98 'deactivated_object_normals_count':str(userdata.deactivated_object_normals_count)}
107 Please enter some comments here! 111 smach.State.__init__(
113 outcomes=[
'succeeded',
'aborted'],
114 input_keys=[
'goal_robot_pose',
115 'goal_ptu_position',])
120 rospy.loginfo(
'Init STATE_RECORDING')
130 <position x="%(goal_camera_pose.position.x)s" y="%(goal_camera_pose.position.y)s" z="%(goal_camera_pose.position.z)s"/> 131 <orientation x="%(goal_camera_pose.orientation.x)s" y="%(goal_camera_pose.orientation.y)s" z="%(goal_camera_pose.orientation.z)s" w="%(goal_camera_pose.orientation.w)s" /> 134 <position x="%(goal_robot_pose.position.x)s" y="%(goal_robot_pose.position.y)s" z="%(goal_robot_pose.position.z)s"/> 135 <orientation x="%(goal_robot_pose.orientation.x)s" y="%(goal_robot_pose.orientation.y)s" z="%(goal_robot_pose.orientation.z)s" w="%(goal_robot_pose.orientation.w)s" /> 137 <goal_ptu_position pan="%(goal_ptu_position.pan)s" tilt="%(goal_ptu_position.tilt)s" /> 145 rospy.loginfo(
'Executing STATE_RECORDING')
150 current_camera_pose = state_acquisition.get_camera_pose_cpp()
152 data = {
'goal_camera_pose.position.x':str(current_camera_pose.position.x),
153 'goal_camera_pose.position.y':str(current_camera_pose.position.y),
154 'goal_camera_pose.position.z':str(current_camera_pose.position.z),
155 'goal_camera_pose.orientation.x':str(current_camera_pose.orientation.x),
156 'goal_camera_pose.orientation.y':str(current_camera_pose.orientation.y),
157 'goal_camera_pose.orientation.z':str(current_camera_pose.orientation.z),
158 'goal_camera_pose.orientation.w':str(current_camera_pose.orientation.w),
159 'goal_robot_pose.position.x':str(userdata.goal_robot_pose.position.x),
160 'goal_robot_pose.position.y':str(userdata.goal_robot_pose.position.y),
161 'goal_robot_pose.position.z':str(userdata.goal_robot_pose.position.z),
162 'goal_robot_pose.orientation.x':str(userdata.goal_robot_pose.orientation.x),
163 'goal_robot_pose.orientation.y':str(userdata.goal_robot_pose.orientation.y),
164 'goal_robot_pose.orientation.z':str(userdata.goal_robot_pose.orientation.z),
165 'goal_robot_pose.orientation.w':str(userdata.goal_robot_pose.orientation.w),
166 'goal_ptu_position.pan':str(userdata.goal_ptu_position[0]),
167 'goal_ptu_position.tilt':str(userdata.goal_ptu_position[1])}
175 if os.path.isfile(path):
176 rospy.loginfo(
"File " + path +
" does exists and will be erased.")
177 open(path,
'w').close()
179 with open(path,
"w+")
as xmlFile:
180 xmlFile.write(
"""<root></root>""")
183 parser = etree.XMLParser(remove_blank_text=
True)
184 tree = etree.parse(path, parser)
186 root = tree.getroot()
187 new_state = etree.XML(xmlToAdd, parser)
188 root.append(new_state)
190 tree._setroot(etree.fromstring(etree.tostring(root, encoding=
'UTF-8', pretty_print=
True)))
def execute(self, userdata)
def execute(self, userdata)
def addXml(path, xmlToAdd)