コード例 #1
0
    def __init__(self, *args):

        super(HardwareTest, self).__init__(*args)
        rospy.init_node('base_test')
        self.message_received = False
        self.sss = simple_script_server()

        try:
            # move_
            if not rospy.has_param('~move_x'):
                self.fail(
                    'Parameter move_x does not exist on ROS Parameter Server')
            self.move_x = rospy.get_param('~move_x')

            if not rospy.has_param('~move_y'):
                self.fail(
                    'Parameter move_ does not exist on ROS Parameter Server')
            self.move_y = rospy.get_param('~move_y')

            if not rospy.has_param('~move_theta'):
                self.fail(
                    'Parameter move_ does not exist on ROS Parameter Server')
            self.move_theta = rospy.get_param('~move_theta')

        except KeyError, e:
            self.fail('Parameters not set properly')
コード例 #2
0
	def __init__(self, *args):
		super(PythonAPITest, self).__init__(*args)
		rospy.init_node('test_python_api_test')
		self.sss=simple_script_server()
		self.as_cb_executed = False
		self.ss_stop_cb_executed = False
		self.ns_global_prefix = "/script_server"
コード例 #3
0
ファイル: sound_test.py プロジェクト: jsanch2s/cob_robots
    def __init__(self, *args):

        super(HardwareTest, self).__init__(*args)
        rospy.init_node('sound_test')
        self.message_received = False
        self.sss = simple_script_server()
        self.record = []
コード例 #4
0
ファイル: sound_test.py プロジェクト: unhelkar/cob_robots
    def __init__(self, *args):

        super(HardwareTest, self).__init__(*args)
        rospy.init_node('test_hardware_test')
        torso_joint_states = []
        self.message_received = False
        self.sss = simple_script_server()
コード例 #5
0
    def __init__(self):

        self.sss = simple_script_server()
        self.detection_service = rospy.ServiceProxy(
            '/object_detection/detect_object', DetectObjects)
        self.arm_state = rospy.Subscriber("/arm_controller/state",
                                          JointTrajectoryControllerState,
                                          self.get_joint_state)
        self.listener = tf.TransformListener(True, rospy.Duration(10.0))

        # initialize components (not needed for simulation)
        """
		self.sss.init("tray")
		self.sss.init("torso")
		self.sss.init("arm")
		self.sss.init("sdh")
		self.sss.init("base")
		"""

        # move to initial positions
        handle_arm = self.sss.move("arm", "folded", False)
        handle_torso = self.sss.move("torso", "home", False)
        handle_sdh = self.sss.move("sdh", "home", False)
        self.sss.move("tray", "down")
        handle_arm.wait()
        handle_torso.wait()
        handle_sdh.wait()

        if not self.sss.parse:
            print "Please localize the robot with rviz"
コード例 #6
0
 def __init__(self):
     self.sss = simple_script_server()
     self.panels = []
     self.stop_buttons = []
     self.init_buttons = []
     self.recover_buttons = []
     self.CreateControlPanel()
コード例 #7
0
 def __init__(self, *args):
     super(UnitTest, self).__init__(*args)
     rospy.init_node('component_test')
     self.message_received = False
     self.sss = simple_script_server()
     self.command_traj = JointTrajectory()
     # get parameters
     try:
         # component
         if not rospy.has_param('~component'):
             self.fail('Parameter component does not exist on ROS Parameter Server')
         self.component = rospy.get_param('~component')
         # movement command
         if not rospy.has_param('~test_target'):
             self.fail('Parameter test_target does not exist on ROS Parameter Server')
         self.test_target = rospy.get_param('~test_target')
         # movement command
         if not rospy.has_param('~default_target'):
              self.fail('Parameter default_target does not exist on ROS Parameter Server')
         self.default_target = rospy.get_param('~default_target')
         # time to wait before
         self.wait_time = rospy.get_param('~wait_time', 5)
         # error range
         if not rospy.has_param('~error_range'):
             self.fail('Parameter error_range does not exist on ROS Parameter Server')
         self.error_range = rospy.get_param('~error_range')
     except KeyError, e:
         self.fail('Parameters not set properly')
コード例 #8
0
    def __init__(self):
        # Visualization topics:
        self.visual_cart_footprint_estimator = rospy.Publisher(
            "/visual_cart_footprint_estimator", PolygonStamped, queue_size=1)
        self.visual_laser_msg = rospy.Publisher("/cart_filtered_scan",
                                                LaserScan,
                                                queue_size=1)
        self.visual_cart = rospy.Publisher("/isolated_cart_scan",
                                           LaserScan,
                                           queue_size=1)

        # The cart status:
        self.the_cart_pub = rospy.Publisher("/cart_is_holded",
                                            String,
                                            queue_size=1)
        self.ref_cart_legs = [(1.375, 0.225), (0.705, 0.225), (0.705, -0.225),
                              (1.375, -0.225)]
        self.the_cart = False

        # Cart footprint estimator message
        self.cart_footprint_estimator = PolygonStamped()
        self.cart_footprint_estimator.header.frame_id = "base_link"

        # Handlers and feedback data:
        self.filtered_laser_msg = LaserScan()
        self.cart_isolated_laser_msg = LaserScan()
        self.laser_projection = lg.LaserProjection()
        self.sss = simple_script_server()
コード例 #9
0
    def __init__(self, num_steps, intervall):

        rospy.init_node("recorder")
        self.sss = simple_script_server()

        #assign members

        self.do_tf = False
        self.do_verbose = True

        self.intervall = intervall

        self.num_steps = num_steps

        self.srv_set_model_state = rospy.ServiceProxy(
            '/gazebo/set_model_state', SetModelState)
        self.req_set = SetModelStateRequest()
        self.req_set.model_state.model_name = "robot"
        self.req_set.model_state.reference_frame = "map"

        if do_tf == True:
            self.tf_br = broadcaster(
                "/map",
                "/odom_combined",
            )
コード例 #10
0
  def __init__(self,buttons):
    global initialized
    self.sss = simple_script_server()
    gtk.Frame.__init__(self)
    self.em_stop = False
    self.set_label("general")
    self.set_shadow_type(gtk.SHADOW_IN)
    self.vbox = gtk.VBox(False, 0)
    self.add(self.vbox)
    #hbox=gtk.HBox(True, 0)
    #image = gtk.Image()
    #image.set_from_file(roslib.packages.get_pkg_dir("cob_command_gui") + "/common/files/icons/batti-040.png")
    #hbox.pack_start(image, False, False, 0)
    #label = gtk.Label("40 %")
    #hbox.pack_start(label, False, False, 0)
    #self.vbox.pack_start(hbox, False, False, 5)
    hbox=gtk.HBox(True, 0)
    self.status_image = gtk.Image()
    #self.status_image.set_from_file(roslib.packages.get_pkg_dir("cob_command_gui") + "/common/files/icons/weather-clear.png")
    hbox.pack_start(self.status_image, False, False, 0)
    self.status_label = gtk.Label("Status OK")
    hbox.pack_start(self.status_label, False, False, 0)
    self.vbox.pack_start(hbox, False, False, 5)

    butstop = gtk.Button("Stop all")
    butstop.connect("clicked", lambda w: self.stop_all(buttons.stop_buttons))
    self.vbox.pack_start(butstop, False, False, 5)

    butinit = gtk.Button("Init all")
    butinit.connect("clicked", lambda w: self.init_all(buttons.init_buttons))
    self.vbox.pack_start(butinit, False, False, 5)

    butrec = gtk.Button("Recover all")
    butrec.connect("clicked", lambda w: self.recover_all(buttons.recover_buttons))
    self.vbox.pack_start(butrec, False, False, 5)

    butrec = gtk.Button("Halt all")
    butrec.connect("clicked", lambda w: self.halt_all(buttons.halt_buttons))
    self.vbox.pack_start(butrec, False, False, 5)

    plan_check = gtk.CheckButton("Planning")#
    plan_check.connect("toggled", self.planned_toggle)
    self.vbox.pack_start(plan_check, False, False, 5)

    base_mode_check = gtk.CheckButton("Base Diff")
    base_mode_check.connect("toggled", self.base_mode_toggle)
    self.vbox.pack_start(base_mode_check, False, False, 5)

    confirm_com_check = gtk.CheckButton("Confirm Commands")
    confirm_com_check.set_active(confirm_commands_enabled)
    confirm_com_check.connect("toggled", self.confirm_com_toggle)
    self.vbox.pack_start(confirm_com_check, False, False, 5)

    but = gtk.Button(stock=gtk.STOCK_QUIT )
    but.connect("clicked", lambda w: gtk.main_quit())
    self.vbox.pack_start(but, False, False, 5)
    initialized = True
コード例 #11
0
 def __init__(self):
     self._sss = sss = simple_script_server()
     #self.sss.init("head")
     sss.init("torso")
     sss.init("arm_left")
     sss.init("arm_right")
     sss.init("gripper_left")
     sss.init("gripper_right")
     sss.init("base")
コード例 #12
0
	def __init__(self, test_type):
		
		self.sss = simple_script_server()

		### GET PARAMETERS ###
		self.base_params = None
		self.actuators = []
		self.sensors = []

		
		if test_type == 'long_time_test':
			self.init_long_time_test()
		elif test_type == 'daily_morning_show':
			self.init_daily_morning_show()
コード例 #13
0
 def __init__(self):
     self.sss = simple_script_server()
     self.station0 = [0, 0, 0.0]
     self.station1 = [15, 7.2, 0.0]
     self.station2 = [33, 0.0, 0.0]
     self.station3 = [26, -37, 0]
     self.station4 = [-9.2, -37, 0]
     self.station5 = self.station3
     self.station6 = self.station0
     self.goals = []
     self.goals.append(self.station0)
     self.goals.append(self.station1)
     self.goals.append(self.station2)
     self.goals.append(self.station3)
     self.goals.append(self.station4)
     self.goals.append(self.station5)
     self.goals.append(self.station6)
コード例 #14
0
    def __init__(self):
        # Visualization topics:
        self.visual_cart_safety_footprint = rospy.Publisher(
            "/visual_cart_safety_footprint", PolygonStamped, queue_size=10)
        self.visual_cart_footprint_estimator = rospy.Publisher(
            "/visual_cart_footprint_estimator", PolygonStamped, queue_size=10)
        self.visual_laser_msg = rospy.Publisher("/cart_filtered_scan",
                                                LaserScan,
                                                queue_size=1)
        self.visual_cart = rospy.Publisher("/isolated_cart_scan",
                                           LaserScan,
                                           queue_size=1)

        # The cart status:
        self.ref_cart_legs = [(1.375, 0.225), (0.705, 0.225), (0.705, -0.225),
                              (1.375, -0.225)]
        self.the_cart = False
        self.cart_legs = []
        self.cart_area = 0.2
        self.cart_wheel_diameter = 0.11
        # Cart safty footprint message
        self.cart_safety_footprint = PolygonStamped()
        self.cart_safety_footprint.header.stamp = rospy.Time.now()
        self.cart_safety_footprint.header.frame_id = "base_link"
        self.cart_safety_footprint.polygon.points = [
            Point(1.375, 0.225, 0.0),
            Point(1.375, -0.225, 0.0),
            Point(0.705, -0.225, 0.0),
            Point(0.705, 0.225, 0.0)
        ]
        # Cart footprint estimator message
        self.cart_footprint_estimator = PolygonStamped()
        self.cart_footprint_estimator.header.frame_id = "base_link"

        # Robot status:
        self.current_position = Odometry()
        self.standing_position = []

        # Handlers and feedback data:
        self.filtered_laser_msg = LaserScan()
        self.cart_isolated_laser_msg = LaserScan()
        self.laser_projection = lg.LaserProjection()
        self.sss = simple_script_server()
コード例 #15
0
    def __init__(self):

        rospy.loginfo("Waiting /arm_kinematics/get_ik service...")
        rospy.wait_for_service('/arm_kinematics/get_ik')
        rospy.loginfo("/arm_kinematics/get_ik has been found!")

        rospy.loginfo("Waiting /get_grasp_configurations service...")
        rospy.wait_for_service('/get_grasp_configurations')
        rospy.loginfo("/get_grasp_configurations has been found!")

        rospy.loginfo("Waiting /get_grasps_from_position service...")
        rospy.wait_for_service('/get_grasps_from_position')
        rospy.loginfo("/get_grasps_from_position has been found!")

        self.sss = simple_script_server()
        self.iks = rospy.ServiceProxy('/arm_kinematics/get_ik', GetPositionIK)

        # initialize components (not needed for simulation)
        self.sss.init("tray")
        self.sss.init("torso")
        self.sss.init("arm")
        self.sss.init("sdh")
        self.sss.init("base")

        # move to initial positions
        #handle_arm = self.sss.move("arm","folded",False)
        #handle_torso = self.sss.move("torso","home",False)
        #handle_sdh = self.sss.move("sdh","home",False)
        #self.sss.move("tray","down")
        #handle_arm.wait()
        #handle_torso.wait()
        #handle_sdh.wait()

        if not self.sss.parse:
            print "Please localize the robot with rviz"
        self.sss.wait_for_input()

        self.listener = tf.TransformListener(True, rospy.Duration(10.0))
        rospy.sleep(2)
コード例 #16
0
    def __init__(self, *args):
        super(UnitTest, self).__init__(*args)
        self.sss = simple_script_server()
        rospy.init_node('tactile_test')
        self.message_received = False
        self.actual_values = []

        try:
            #tactile topic
            if not rospy.has_param('~topic'):
                self.fail(
                    'Parameter topic does not exist on ROS Parameter Server')
            self.topic = rospy.get_param('~topic')
            # minimum required value
            if not rospy.has_param('~min_tactile_value'):
                self.fail(
                    'Parameter min_tactile_value does not exist on ROS Parameter Server'
                )
            self.min_tactile_value = rospy.get_param('~min_tactile_value')

        except KeyError, e:
            self.fail('Parameters not set properly')
コード例 #17
0
    def __init__(self):

        self.sss = simple_script_server()
        self.pose = ''
        self.joint_state = []

        try:
            opts, args = getopt.getopt(sys.argv[1:], "h:p:", ["pose="])
            rospy.loginfo(args)
        except getopt.GetoptError:
            print 'python save_position.py -p <posename>'
            sys.exit(2)
        for opt, arg in opts:
            if opt == '-h':
                print 'python save_position.py -p <posename>'
                sys.exit()
            elif opt in ("-p", "--pose"):
                self.pose = arg
            else:
                print 'Invalid syntax, please use "python save_position.py -p <posename>"'

        rospy.loginfo(self.pose)

        if self.pose == '':
            rospy.logerr("posename cannot be empty")
            print 'python save_position.py -p <posename>'
            sys.exit()

        rospy.loginfo(self.pose)

        self.param = '/script_server/arm/' + self.pose

        rospy.loginfo(self.param)

        self.ready = 0

        rospy.Subscriber('/arm_controller/state',
                         JointTrajectoryControllerState, self.get_joint_state)
コード例 #18
0
    def __init__(self, *args):
        super(UnitTest, self).__init__(*args)
        rospy.init_node('calibration_test')
        self.message_received = False
        self.sss = simple_script_server()


        # get parameters
        try:
            # movement command
            if not rospy.has_param('~test_target_torso'):
                self.fail('Parameter test_target_torso does not exist on ROS Parameter Server')
            self.test_target_torso = rospy.get_param('~test_target_torso')

            if not rospy.has_param('~test_target_head'):
                 self.fail('Parameter test_target_head does not exist on ROS Parameter Server')
            self.test_target_head = rospy.get_param('~test_target_head')
            
            if not rospy.has_param('~test_target_arm'):
                 self.fail('Parameter test_target_arm does not exist on ROS Parameter Server')
            self.test_target_arm = rospy.get_param('~test_target_arm')            

        except KeyError, e:
            self.fail('Parameters not set properly')
コード例 #19
0
ファイル: demo_arm.py プロジェクト: bosforox/SeekurJr
 def __init__(self):
    
     self.available_poses = ['home', 'folded', 'waveleft', 'waveright']
     self.sss = simple_script_server()
コード例 #20
0
def run():
    test = ComponentTest('daily_morning_show')
    #light_test = HardwareTest('daily_morning_show_lights')
    sss = simple_script_server()

    # Check that em_stop is not pressed
    while test.check_em_stop():
        dialog_client(0, 'Release EM-stop and press ' 'OK' '')

    # Initialize
    test.log_file.write('\n[INITIALIZE] [%s]' % (time.strftime('%H:%M:%S')))
    if test.base_params:
        test.log_file.write('\n  base: ')
        if test.init_component('base'):
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')

    for component in test.actuators:
        test.log_file.write('\n  %s: ' % (component['name']))
        if test.init_component(component['name']):
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')

    rospy.sleep(1)

    #### MOVE TEST 1 ###
    test.log_file.write('\n\n[MOVE_TEST_1] [%s]' % (time.strftime('%H:%M:%S')))
    if test.base_params:
        # Move base
        test.log_file.write('\n  base: ')
        if test.move_base_rel(test.base_params) and dialog_client(
                1, 'Did the robot move?'):
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')
            test.get_diagnostics('base')

    # Move actuators
    for component in test.actuators:
        test.log_file.write('\n  %s: ' % (component['name']))
        if test.move_actuator_daily(component) and test.dialog(
                component['name'], component['test_target']):
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')
            test.get_diagnostics(component['name'])

    ### RECOVER TEST ###
    test.log_file.write('\n\n[RECOVER_TEST] [%s]' %
                        (time.strftime('%H:%M:%S')))
    test.recover_test()

    ### MOVE TEST 2 ###
    test.log_file.write('\n\n[MOVE_TEST_2] [%s]' % (time.strftime('%H:%M:%S')))
    if test.base_params:
        # Move base
        test.log_file.write('\n  base: ')
        if test.move_base_rel(test.base_params) and dialog_client(
                1, 'Did the robot move?'):
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')
            test.get_diagnostics('base')

    # Move actuators
    for component in test.actuators:
        test.log_file.write('\n  %s: ' % (component['name']))
        if test.move_actuator_daily(component) and test.dialog(
                component['name'], component['test_target']):
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')
            test.get_diagnostics(component['name'])

    # Change lights, test mimics and sound
    # This part is completely "hardcoded", only use with Cob4!
    if True:
        test.log_file.write('\n\n[MIMICS, SOUNDS & LEDS] [%s]' %
                            (time.strftime('%H:%M:%S')))
        test.log_file.write('\n  mimics:')
        sss.set_mimic("mimic", "asking")
        rospy.sleep(1)
        mimic_working = dialog_client(1, 'Do you see the question-mark?')
        sss.set_mimic("mimic", "default")
        if mimic_working:
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')
        test.log_file.write('\n  sound:')
        sss.say(["test 1, 2, 3"])
        rospy.sleep(1)
        sound_working = dialog_client(
            1, 'Did you hear me speak? (Next: Lights, so pay attention!)')
        if sound_working:
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')
        test.log_file.write('\n  LEDs:')
        sss.set_light("light_base", "cyan")
        sss.set_light("light_torso", "cyan")
        rospy.sleep(1.0)
        sss.set_light("light_base", "yellow")
        sss.set_light("light_torso", "yellow")
        rospy.sleep(3.0)
        sss.set_light("light_base", "red")
        sss.set_light("light_torso", "red")
        rospy.sleep(3.0)
        sss.set_light("light_base", "cyan")
        sss.set_light("light_torso", "cyan")
        rospy.sleep(3.0)
        lights_changed = dialog_client(
            1,
            'Did you see the lights change from "cyan" to "yellow" to "red" and back?'
        )
        if lights_changed:
            test.log_file.write('\t<<OK>>')
        else:
            test.log_file.write('\t<<FAIL>>')

    # Sensor test
    test.log_file.write('\n\n[SENSOR_TEST] [%s]' % (time.strftime('%H:%M:%S')))

    for sensor in test.sensors:
        test.log_file.write('\n  %s: ' % (sensor['name']))

        if test.check_sensor(sensor['topic'], sensor['msg_type']):
            test.log_file.write('<<OK>>')
        else:
            test.log_file.write('<<NO_MSG>>')

    test.log_file.close()
コード例 #21
0
def main():
    rospy.init_node('tf_position_retrieval')

    tf_listener = tf.TransformListener()

    #subscribe to tf message where the pattern information are published
    rospy.Subscriber("/tf", tf.msg.tfMessage, cb_tf)

    #todo: read in pose list from parameter server
    if (not rospy.has_param("/script_server/arm/calibration_poses")):
        rospy.logerr("No arm calibration poses given.")
        exit(0)
    else:
        calib_poses = sorted(
            rospy.get_param("/script_server/arm/calibration_poses"))
        rospy.loginfo("arm calibration poses: %s", calib_poses)

    kinect_transforms = []

    #create instance of script server
    sss = simple_script_server()

    for item in calib_poses:
        #move arm to the given position (blocking call
        print "start move arm"
        sss.move("arm", item)
        print "arm arrived"

        rospy.sleep(2.0)

        time_after_movement = rospy.Time.now()

        # only take pose if time stamp is new than the time directly after the arm movement
        while ((last_pattern_transform.header.stamp - time_after_movement) <=
               0):
            print "wait for newest time stamp"
            rospy.spin()

        #current_transform = last_pattern_transform.transform
        print "loopup transform"
        (trans, rot) = tf_listener.lookupTransform('/base_link',
                                                   '/openni_camera',
                                                   rospy.Time(0))

        current_transform.transform.translation = trans
        current_transform.transform.rotation = rot

        kinect_transforms.append(current_transform)

    print "calc mean"

    #calculate the mean
    mean_x = 0
    mean_y = 0
    mean_z = 0
    mean_roll = 0
    mean_pitch = 0
    mean_raw = 0

    for item in kinect_transforms:
        mean_x += item.transform.translation.x
        mean_y += item.transform.translation.y
        mean_z += item.transform.translation.z

        (roll, pitch, yaw) = tf.transformations.euler_from_quaternion([
            item.transform.rotation.x, item.transform.rotation.y,
            item.transform.rotation.z, item.transform.rotation.w
        ])
        mean_roll += roll
        mean_pitch += pitch
        mean_yaw += yaw

    mean_x /= len(kinect_transforms)
    mean_y /= len(kinect_transforms)
    mean_z /= len(kinect_transforms)
    mean_roll /= len(kinect_transforms)
    mean_pitch /= len(kinect_transforms)
    mean_raw /= len(kinect_transforms)

    rospy.loginfo("%s %s %s %s %s %s", mean_x, mean_y, mean_z, mean_roll,
                  mean_pitch, mean_yaw)
コード例 #22
0
 def __init__(self):
     self._sss = simple_script_server()
     self._sss.say("sound", ["I am listening to you"])
コード例 #23
0
 def __init__(self):
     self.sss = simple_script_server()
     self.station1 = [40, -3, 1.57]
     self.station2 = [40, -10, -1.57]
     self.station3 = [39.2, -23, 0]
     self.num_iterations = 10
コード例 #24
0
	def init_long_time_test(self):
		rospy.init_node('component_test_all')
		
		### GET PARAMETERS ###
		self.wait_time = 3			# waiting time (in seconds) for state message
		self.wait_time_recover = 1	
		
		# Message types
		self.actuator_msg = JointTrajectoryControllerState
		self.scan_msg = LaserScan
		self.kinect_msg = PointCloud2
		self.image_msg = Image
		
		self.msg_received = False
		self.sss = simple_script_server()	
		
		# Get base goals
		try:
			params = rospy.get_param('/component_test/components/base/params')
			params.update(rospy.get_param('/component_test/components/base/goals'))
			self.base_params = params
			self.base_params['performed_tests'] = 0
			self.base_params['recovered_tests'] = 0
			self.base_params['failed_tests'] = 0
		except:
			pass
		

		# Get actuator parameters
		try:
			params_actuator = rospy.get_param('/component_test/components/actuators')
			for k in params_actuator.keys():
				params_actuator[k]['performed_tests'] = 0
				params_actuator[k]['recovered_tests'] = 0
				params_actuator[k]['failed_tests'] = 0
				self.actuators.append(params_actuator[k])
		except:
			pass
			
		# Get sensor parameters	
		try:
			params = rospy.get_param('/component_test/components/sensors')
			for k in params.keys():
				self.sensors.append(params[k])
		except:
			pass
			
		if not self.base_params and not self.actuators and not self.sensors:
			raise NameError('Couldn\'t find any components to test under /component_test namespace. '
							'You need to define at least one component in order to run the program (base, actuator, sensor). '
							'View the documentation to see how to define test-components.')
		
			
		# Get maximum test duration and rounds
		self.test_duration = None
		self.test_rounds = None
		try:
			self.test_duration = 60.0 * float(rospy.get_param('/component_test/test_duration'))
		except:
			pass
		try:
			self.test_rounds = int(rospy.get_param('/component_test/test_rounds'))
		except:
			pass
		if not self.test_duration and not self.test_rounds:
			raise NameError('Both maximum duration and maximum test rounds are undefined!'
							'\nPlease pass at least one of the two parameters. '
							'\nMax duration must be given in minutes and max rounds as an integer.')
		# if one of the duration-limiting parameters is not set, we set it to "infinite"
		if self.test_duration == None or self.test_duration == 0:
			self.test_duration = 1e100
		if self.test_rounds == None or self.test_rounds == 0:
			self.test_rounds = 1e100
		
		
		# Get log-file directory
		try:
			log_dir = rospy.get_param('/component_test/result_dir')
		except:
			raise NameError('Test-result directory is undefined.')
		
		
		# Subscribe to toplevel-state topic
		self.toplevel_state_received = False
		sub_top_state = rospy.Subscriber("/diagnostics_toplevel_state", DiagnosticStatus, self.cb_toplevel_state)
		abort_time = rospy.Time.now() + rospy.Duration(self.wait_time)
		while not self.toplevel_state_received and rospy.get_rostime() < abort_time:
			rospy.sleep(0.1)
		if not self.toplevel_state_received:
			raise NameError('Could not subscribe to "/diagnostics_toplevel_state" topic')
		self.toplevel_error = False
		
		
		# Create and prepare log file		
		if self.base_params or self.actuators:
			complete_name = '%s/component_test_results_%s.txt' %(log_dir, time.strftime("%Y%m%d_%H-%M"))
			self.log_file = open(complete_name,'w')
			
			# Log all tested components
			self.log_file.write('Long-term component test')
			self.log_file.write('\n%s \n%s' %(time.strftime('%d.%m.%Y'), time.strftime('%H:%M:%S')))
			self.print_topic('TESTED COMPONENTS')
			if self.base_params:
				self.log_file.write('\n  base')
			if self.actuators:
				for actuator in self.actuators:
					self.log_file.write('\n  ' + actuator['name'])
					
			# Log test parameters
			self.print_topic('TEST PARAMETERS')
			params = rospy.get_param('/component_test/components')
			for key in params:
				self.log_file.write('\n%s:' %(key))
				params_2 = rospy.get_param('/component_test/components/%s' %(key))
				for key_2 in params_2:
					self.log_file.write('\n  %s:' %(key_2))
					params_3 = rospy.get_param('/component_test/components/%s/%s' %(key, key_2))
					for key_3, value in params_3.iteritems():
						self.log_file.write('\n    %s: %s' %(key_3, value))
			
			
			self.print_topic('TEST LOG')
			
			self.log_file.write('\n[<ROUND_NO.>] [<TIMESTAMP>]'
								'\n  <COMPONENT> \t[<DURATION>]')
コード例 #25
0
 def __init__(self, *args):
     super(UnitTest, self).__init__(*args)
     rospy.init_node('component_test')
     self.message_received = False
     self.sss = simple_script_server()
コード例 #26
0
 def __init__(self, *args):
     super(UnitTest, self).__init__(*args)
     rospy.init_node(NAME)
     self.sss = simple_script_server()
コード例 #27
0
 def __init__(self):
     self.sss = simple_script_server()
     self.panels = []
     self.CreateControlPanel()
コード例 #28
0
 def __init__(self):
     self.script_action_server = actionlib.SimpleActionServer(
         "cob_command_gui_rviz", ScriptAction, self.execute_cb, False)
     self.script_action_server.start()
     self.sss = simple_script_server()
コード例 #29
0
# GNU Lesser General Public License LGPL for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License LGPL along with this program.
# If not, see <http://www.gnu.org/licenses/>.
#
#################################################################

import roslib
roslib.load_manifest('cob_monitoring')
import rospy

from cob_msgs.msg import *

from simple_script_server import *
sss = simple_script_server()


class battery_monitor():
    def __init__(self):
        rospy.Subscriber("/power_state", PowerState, self.power_state_callback)
        self.rate = rospy.Rate(1 / 10.0)  # check every 10 sec
        self.warn_announce_time = rospy.Duration(300.0)
        self.error_announce_time = rospy.Duration(120.0)
        self.last_announced_time = rospy.Time.now()

    ## Battery monitoring
    ### TODO: make values parametrized through yaml file (depending on env ROBOT)
    def power_state_callback(self, msg):
        if msg.relative_capacity <= 10.0:
            rospy.logerr("Battery empty, recharge now! Battery state is at " +
コード例 #30
0
	def __init__(self):
		self.sss = simple_script_server()
		self.action_server = actionlib.SimpleActionServer("/sdh_gripper_grasp_posture_controller", GraspHandPostureExecutionAction, self.execute, False)
		self.query_service = rospy.Service('/sdh_gripper_grasp_status', GraspStatus, self.query_cb)
		self.action_server.start()
		time.sleep(1)