WUT Velma robot API
initialize_robot.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 
3 
7 
8 # Copyright (c) 2017, Robot Control and Pattern Recognition Group,
9 # Institute of Control and Computation Engineering
10 # Warsaw University of Technology
11 #
12 # All rights reserved.
13 #
14 # Redistribution and use in source and binary forms, with or without
15 # modification, are permitted provided that the following conditions are met:
16 # * Redistributions of source code must retain the above copyright
17 # notice, this list of conditions and the following disclaimer.
18 # * Redistributions in binary form must reproduce the above copyright
19 # notice, this list of conditions and the following disclaimer in the
20 # documentation and/or other materials provided with the distribution.
21 # * Neither the name of the Warsaw University of Technology nor the
22 # names of its contributors may be used to endorse or promote products
23 # derived from this software without specific prior written permission.
24 #
25 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
26 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
27 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
28 # DISCLAIMED. IN NO EVENT SHALL <COPYright HOLDER> BE LIABLE FOR ANY
29 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
31 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
32 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
34 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 #
36 # Author: Dawid Seredynski
37 #
38 
39 import roslib; roslib.load_manifest('velma_task_cs_ros_interface')
40 import rospy
41 import PyKDL
42 
43 from velma_common import *
44 from rcprg_ros_utils import exitError
45 
46 if __name__ == "__main__":
47 
48  rospy.init_node('test_init', anonymous=False)
49 
50  rospy.sleep(0.5)
51 
52  print "This test/tutorial executes initialization"\
53  " procedures required for robot operation.\n"
54 
55  print "Running python interface for Velma..."
56  velma = VelmaInterface()
57  print "Waiting for VelmaInterface initialization..."
58  if not velma.waitForInit(timeout_s=10.0):
59  print "Could not initialize VelmaInterface\n"
60  exitError(1)
61  print "Initialization ok!\n"
62 
63  print "Motors must be enabled every time after the robot enters safe state."
64  print "If the motors are already enabled, enabling them has no effect."
65  print "Enabling motors..."
66  if velma.enableMotors() != 0:
67  exitError(14)
68 
69  print "Also, head motors must be homed after start-up of the robot."
70  print "Sending head pan motor START_HOMING command..."
71  velma.startHomingHP()
72  if velma.waitForHP() != 0:
73  exitError(14)
74  print "Head pan motor homing successful."
75 
76  print "Sending head tilt motor START_HOMING command..."
77  velma.startHomingHT()
78  if velma.waitForHT() != 0:
79  exitError(15)
80  print "Head tilt motor homing successful."
81 
82  exitError(0)
83