initialize_baxter.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 # -*- coding: utf-8 -*-
00003 #
00004 import argparse
00005 from baxter_core_msgs.msg import AssemblyState
00006 import baxter_interface
00007 from baxter_interface import CHECK_VERSION
00008 from multiprocessing import Pool
00009 from rosgraph_msgs.msg import Clock
00010 import rospy
00011 import subprocess
00012 
00013 
00014 def main():
00015     parser = argparse.ArgumentParser()
00016     parser.add_argument('--moveit', '-m', action='store_true')
00017     args = parser.parse_args(rospy.myargv()[1:])
00018 
00019     rospy.init_node('initialize_baxter')
00020 
00021     rospy.loginfo('waiting for /clock & /robot/state')
00022     rospy.wait_for_message('/clock', Clock)
00023     rospy.wait_for_message('/robot/state', AssemblyState)
00024     rospy.loginfo('found /clock & /robot/state')
00025 
00026     # enable robot
00027     baxter_interface.RobotEnable(CHECK_VERSION).enable()
00028 
00029     # joint action server
00030     pool = Pool(processes=3)
00031     commands = [
00032         ('rosrun', 'baxter_interface', 'joint_trajectory_action_server.py'),
00033         ('rosrun', 'baxter_interface', 'head_action_server.py')]
00034     if args.moveit:
00035         commands.append((
00036             'roslaunch', 'baxter_moveit_config', 'move_group.launch'))
00037     pool.map(subprocess.call, commands)
00038 
00039 
00040 if __name__ == '__main__':
00041     main()


jsk_baxter_startup
Author(s):
autogenerated on Sat Jul 1 2017 02:42:02