当前位置: 首页>>代码示例>>Python>>正文


Python rospkg.RosPack方法代码示例

本文整理汇总了Python中rospkg.RosPack方法的典型用法代码示例。如果您正苦于以下问题:Python rospkg.RosPack方法的具体用法?Python rospkg.RosPack怎么用?Python rospkg.RosPack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rospkg的用法示例。


在下文中一共展示了rospkg.RosPack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def __init__(self):
        # Audio stream input setup
        FORMAT = pyaudio.paInt16
        CHANNELS = 1
        RATE = 16000
        self.CHUNK = 4096
        self.audio = pyaudio.PyAudio()
        self.stream = self.audio.open(format=FORMAT, channels=CHANNELS,
                                      rate=RATE, input=True,
                                      frames_per_buffer=self.CHUNK,
                                      stream_callback=self.get_data)
        self._buff = Queue.Queue()  # Buffer to hold audio data
        self.closed = False

        # ROS Text Publisher
        self.text_pub = rospy.Publisher('/google_client/text', String, queue_size=10)

        # Context clues in yaml file
        rospack = rospkg.RosPack()
        yamlFileDir = rospack.get_path('dialogflow_ros') + '/config/context.yaml'
        with open(yamlFileDir, 'r') as f:
            self.context = yaml.load(f) 
开发者ID:piraka9011,项目名称:dialogflow_ros,代码行数:24,代码来源:google_client.py

示例2: __init__

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def __init__(self, config_name, srdf_file, move_group = "", robot_name = ""):
		'''
		Constructor
		'''
		super(GetJointsFromSrdfState, self).__init__(outcomes=['retrieved', 'file_error'],
												output_keys=['joint_values'])

		self._config_name = config_name
		self._move_group = move_group
		self._robot_name = robot_name

		# Check existence of SRDF file to reduce risk of runtime failure.
		# Anyways, values will only be read during runtime to allow modifications.
		self._srdf_path = None
		try:
			rp = RosPack()
			pkg_name = srdf_file.split('/')[0]
			self._srdf_path = os.path.join(rp.get_path(pkg_name), '/'.join(srdf_file.split('/')[1:]))
			if not os.path.isfile(self._srdf_path):
				raise IOError('File "%s" does not exist!' % self._srdf_path)
		except Exception as e:
			Logger.logwarn('Unable to find given SRDF file: %s\n%s' % (srdf_file, str(e)))

		self._file_error = False
		self._srdf = None 
开发者ID:FlexBE,项目名称:generic_flexbe_states,代码行数:27,代码来源:get_joints_from_srdf_state.py

示例3: spawn_model

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def spawn_model(model_name):
    """ Spawns a model in front of the RGBD camera.

        Args: None

        Returns: None
    """
    initial_pose = Pose()
    initial_pose.position.x = 0
    initial_pose.position.y = 1
    initial_pose.position.z = 1

    # Spawn the new model #
    model_path = rospkg.RosPack().get_path('sensor_stick')+'/models/'
    model_xml = ''

    with open (model_path + model_name + '/model.sdf', 'r') as xml_file:
        model_xml = xml_file.read().replace('\n', '')

    spawn_model_prox = rospy.ServiceProxy('gazebo/spawn_sdf_model', SpawnModel)
    spawn_model_prox('training_model', model_xml, '', initial_pose, 'world') 
开发者ID:udacity,项目名称:RoboND-Perception-Exercises,代码行数:23,代码来源:training_helper.py

示例4: running_times

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def running_times():
    rospack = rospkg.RosPack()
    data_path = os.path.join(rospack.get_path('vslam_evaluation'), 'out')
    df = pd.read_csv(os.path.join(data_path, 'runtimes.txt'),
        header=None,
        index_col=0)

    bars = []

    for col_idx in df:
        this_stack = df[col_idx].dropna()
        bars.append(
            go.Bar(
                x=this_stack.index,
                y=this_stack.values,
                name='Thread {}'.format(col_idx)))

    layout = go.Layout(
        barmode='stack',
        yaxis={'title': 'Running time [s]'})

    fig = go.Figure(data=bars, layout=layout)

    url = py.plot(fig, filename='vslam_eval_run_times') 
开发者ID:nicolov,项目名称:vslam_evaluation,代码行数:26,代码来源:plot_plotly.py

示例5: read_cfg

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def read_cfg(self, cfg_filename):
        """
        Reads the configuration file

        :param cfg_filename: configuration file name for ORB-SLAM2

        :type cfg_filename: string

        :return: configurations in the configuration file
        :rtype: dict
        """
        rospack = rospkg.RosPack()
        slam_pkg_path = rospack.get_path("orb_slam2_ros")
        cfg_path = os.path.join(slam_pkg_path, "cfg", cfg_filename)
        with open(cfg_path, "r") as f:
            for i in range(1):
                f.readline()
            cfg_data = yaml.load(f)
        return cfg_data 
开发者ID:facebookresearch,项目名称:pyrobot,代码行数:21,代码来源:pcdlib.py

示例6: read_cfg

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def read_cfg(self, cfg_filename):
        """
        Reads the configuration file

        :param cfg_filename: configuration file name for ORB-SLAM2

        :type cfg_filename: string

        :return: configurations in the configuration file
        :rtype: dict
        """
        rospack = rospkg.RosPack()
        slam_pkg_path = rospack.get_path("orb_slam2_ros")
        cfg_path = os.path.join(slam_pkg_path, "cfg", cfg_filename)
        with open(cfg_path, "r") as f:
            for i in range(1):
                f.readline()
            cfg_data = yaml.load(f, Loader=yaml.FullLoader)
        return cfg_data 
开发者ID:facebookresearch,项目名称:pyrobot,代码行数:21,代码来源:camera.py

示例7: test_face_properties

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def test_face_properties():
    test_key = '69efefc20c7f42d8af1f2646ce6742ec'
    test_secret = '5fab420ca6cf4ff28e7780efcffadb6c'

    def age_is_female_from_asset_name(asset_name):
        age_str, gender_str = re.search("age_(\d+)_gender_(\w+)", asset_name).groups()
        return int(age_str), gender_str == "female"

    assets_path = os.path.join(rospkg.RosPack().get_path("image_recognition_skybiometry"), 'test/assets')
    images_gt = [(cv2.imread(os.path.join(assets_path, asset)), age_is_female_from_asset_name(asset))
                 for asset in os.listdir(assets_path)]

    estimations = Skybiometry(test_key, test_secret).get_face_properties([image for image, _ in images_gt], 10.0)
    for (_, (age_gt, is_female_gt)), face_property in zip(images_gt, estimations):
        age = int(face_property.age_est.value)
        is_female = face_property.gender.value == "female"
        # assert abs(age - age_gt) <= 5  # Poor performance
        assert is_female == is_female_gt 
开发者ID:tue-robotics,项目名称:image_recognition,代码行数:20,代码来源:test_face_properties.py

示例8: test_face_properties

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def test_face_properties():
    local_path = "/tmp/age_gender_weights.hdf5"

    if not os.path.exists(local_path):
        http_path = "https://github.com/tue-robotics/image_recognition/releases/download/" \
                    "image_recognition_keras_face_properties_weights.28-3.73/" \
                    "image_recognition_keras_face_properties_weights.28-3.73.hdf5"
        urllib.urlretrieve(http_path, local_path)
        print("Downloaded weights to {}".format(local_path))

    def age_is_female_from_asset_name(asset_name):
        age_str, gender_str = re.search("age_(\d+)_gender_(\w+)", asset_name).groups()
        return int(age_str), gender_str == "female"

    assets_path = os.path.join(rospkg.RosPack().get_path("image_recognition_keras"), 'test/assets')
    images_gt = [(cv2.imread(os.path.join(assets_path, asset)), age_is_female_from_asset_name(asset))
                 for asset in os.listdir(assets_path)]

    estimations = AgeGenderEstimator(local_path, 64, 16, 8).estimate([image for image, _ in images_gt])
    for (_, (age_gt, is_female_gt)), (age, gender) in zip(images_gt, estimations):
        age = int(age)
        is_female = gender[0] > 0.5
        assert abs(age - age_gt) < 5
        assert is_female == is_female_gt 
开发者ID:tue-robotics,项目名称:image_recognition,代码行数:26,代码来源:test_face_properties.py

示例9: _setup

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def _setup(self):
        '''
        Create the mug at a random position on the ground, handle facing
        roughly towards the robot. Robot's job is to grab and lift.
        '''

        rospack = rospkg.RosPack()
        path = rospack.get_path('costar_objects')
        sdf_dir = os.path.join(path, self.sdf_dir)
        obj_to_add = os.path.join(sdf_dir, self.model, self.model_file_name)

        identity_orientation = pb.getQuaternionFromEuler([0, 0, 0])
        try:
            obj_id_list = pb.loadSDF(obj_to_add)
            for obj_id in obj_id_list:
                random_position = np.random.rand(
                    3) * self.spawn_pos_delta + self.spawn_pos_min
                pb.resetBasePositionAndOrientation(
                    obj_id, random_position, identity_orientation)
        except Exception, e:
            print e 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:23,代码来源:mug.py

示例10: _setup

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def _setup(self):
        '''
        Create the mug at a random position on the ground, handle facing
        roughly towards the robot. Robot's job is to grab and lift.
        '''

        rospack = rospkg.RosPack()
        path = rospack.get_path('costar_simulation')
        urdf_dir = os.path.join(path, self.urdf_dir)
        tray_filename = os.path.join(urdf_dir, self.tray_dir, self.tray_urdf)
        red_filename = os.path.join(urdf_dir, self.model, self.red_urdf)
        blue_filename = os.path.join(urdf_dir, self.model, self.blue_urdf)

        for position in self.tray_poses:
            obj_id = pb.loadURDF(tray_filename)
            pb.resetBasePositionAndOrientation(obj_id, position, (0, 0, 0, 1))

        self._add_balls(self.num_red, red_filename, "red")
        self._add_balls(self.num_blue, blue_filename, "blue") 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:21,代码来源:sorting.py

示例11: load

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def load(self):
        '''
        This is an example of a function that allows you to load a robot from
        file based on command line arguments. It just needs to find the
        appropriate directory, use xacro to create a temporary robot urdf,
        and then load that urdf with PyBullet.
        '''

        rospack = rospkg.RosPack()
        path = rospack.get_path('costar_simulation')
        filename = os.path.join(path, self.xacro_filename)
        urdf_filename = os.path.join(path, 'robot', self.urdf_filename)
        urdf = open(urdf_filename, "w")

        # Recompile the URDF to make sure it's up to date
        subprocess.call(['rosrun', 'xacro', 'xacro.py', filename], stdout=urdf)

        self.handle = pb.loadURDF(urdf_filename)
        self.grasp_idx = self.findGraspFrame()
        #self.loadKinematicsFromURDF(urdf_filename, "base_link")

        return self.handle 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:24,代码来源:turtlebot.py

示例12: load

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def load(self):
        '''
        This is an example of a function that allows you to load a robot from
        file based on command line arguments. It just needs to find the
        appropriate directory, use xacro to create a temporary robot urdf,
        and then load that urdf with PyBullet.
        '''

        rospack = rospkg.RosPack()
        path = rospack.get_path('costar_simulation')
        filename = os.path.join(path, self.xacro_filename)
        urdf_filename = os.path.join(path, 'robot', self.urdf_filename)
        urdf = open(urdf_filename, "w")

        # Recompile the URDF to make sure it's up to date
        subprocess.call(['rosrun', 'xacro', 'xacro.py', filename], stdout=urdf)

        self.handle = pb.loadURDF(urdf_filename)

        return self.handle 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:22,代码来源:iiwa_robotiq_3_finger.py

示例13: load

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def load(self):
        '''
        This is an example of a function that allows you to load a robot from
        file based on command line arguments. It just needs to find the
        appropriate directory, use xacro to create a temporary robot urdf,
        and then load that urdf with PyBullet.
        '''

        rospack = rospkg.RosPack()
        path = rospack.get_path('costar_simulation')
        filename = os.path.join(path, self.xacro_filename)
        urdf_filename = os.path.join(path, 'robot', self.urdf_filename)
        urdf = open(urdf_filename, "w")

        # Recompile the URDF to make sure it's up to date
        subprocess.call(['rosrun', 'xacro', 'xacro.py', filename], stdout=urdf)

        self.handle = pb.loadURDF(urdf_filename)
        self.grasp_idx = self.findGraspFrame()
        self.loadKinematicsFromURDF(urdf_filename, "base_link")

        return self.handle 
开发者ID:jhu-lcsr,项目名称:costar_plan,代码行数:24,代码来源:ur5_robotiq.py

示例14: __init__

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def __init__(self):
		self._behavior_started = False
		self._preempt_requested = False
		self._current_state = None
		self._active_behavior_id = None

		self._pub = rospy.Publisher('flexbe/start_behavior', BehaviorSelection, queue_size=100)
		self._preempt_pub = rospy.Publisher('flexbe/command/preempt', Empty, queue_size=100)
		self._status_sub = rospy.Subscriber('flexbe/status', BEStatus, self._status_cb)
		self._state_sub = rospy.Subscriber('flexbe/behavior_update', String, self._state_cb)

		self._as = actionlib.SimpleActionServer('flexbe/execute_behavior', BehaviorExecutionAction, None, False)
		self._as.register_preempt_callback(self._preempt_cb)
		self._as.register_goal_callback(self._goal_cb)

		self._rp = RosPack()
		self._behavior_lib = BehaviorLibrary()

		# start action server after all member variables have been initialized
		self._as.start()

		rospy.loginfo("%d behaviors available, ready for start request." % self._behavior_lib.count_behaviors()) 
开发者ID:team-vigir,项目名称:flexbe_behavior_engine,代码行数:24,代码来源:behavior_action_server.py

示例15: __init__

# 需要导入模块: import rospkg [as 别名]
# 或者: from rospkg import RosPack [as 别名]
def __init__(self):
		Logger.initialize()

		self._ready_event = threading.Event()

		self._sub = rospy.Subscriber("flexbe/request_behavior", BehaviorRequest, self._callback)
		self._version_sub = rospy.Subscriber("flexbe/ui_version", String, self._version_callback)

		self._pub = rospy.Publisher("flexbe/start_behavior", BehaviorSelection, queue_size=100)
		self._status_pub = rospy.Publisher("flexbe/status", BEStatus, queue_size=100)
		self._status_sub = rospy.Subscriber("flexbe/status", BEStatus, self._status_callback)
		self._mirror_pub = rospy.Publisher("flexbe/mirror/structure", ContainerStructure, queue_size=100)

		self._rp = RosPack()
		self._behavior_lib = BehaviorLibrary()

		rospy.loginfo("%d behaviors available, ready for start request." % self._behavior_lib.count_behaviors()) 
开发者ID:team-vigir,项目名称:flexbe_behavior_engine,代码行数:19,代码来源:behavior_launcher.py


注:本文中的rospkg.RosPack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。