コード例 #1
0
ファイル: test_roslib_names.py プロジェクト: daju1-ros/ros
    def test_make_caller_id(self):
        from roslib.names import make_caller_id
        if 'ROS_NAMESPACE' is os.environ:
            rosns = os.environ['ROS_NAMESPACE']
            del os.environ['ROS_NAMESPACE']
        else:
            rosns = None

        for n in ['~name']:
            try:
                make_caller_id('~name')  # illegal
                self.fail("make_caller_id should fail on %s" % n)
            except ValueError:
                pass

        self.assertEquals('/node/', make_caller_id('node'))
        self.assertEquals('/bar/node/', make_caller_id('bar/node'))
        self.assertEquals('/bar/node/', make_caller_id('/bar/node'))

        os.environ['ROS_NAMESPACE'] = '/test/'
        self.assertEquals('/test/node/', make_caller_id('node'))
        self.assertEquals('/test/bar/node/', make_caller_id('bar/node'))
        self.assertEquals('/bar/node/', make_caller_id('/bar/node'))

        # restore
        if rosns:
            os.environ['ROS_NAMESPACE'] = rosns
コード例 #2
0
ファイル: test_roslib_names.py プロジェクト: lubosz/rosstacks
  def test_make_caller_id(self):
    from roslib.names import make_caller_id
    if 'ROS_NAMESPACE' is os.environ:
      rosns = os.environ['ROS_NAMESPACE']
      del os.environ['ROS_NAMESPACE']
    else:
      rosns = None

    for n in ['~name']:
      try:
        make_caller_id('~name') # illegal
        self.fail("make_caller_id should fail on %s"%n)
      except ValueError: pass
    
    self.assertEquals('/node/', make_caller_id('node'))
    self.assertEquals('/bar/node/', make_caller_id('bar/node'))
    self.assertEquals('/bar/node/', make_caller_id('/bar/node'))        

    os.environ['ROS_NAMESPACE'] = '/test/'
    self.assertEquals('/test/node/', make_caller_id('node'))
    self.assertEquals('/test/bar/node/', make_caller_id('bar/node'))
    self.assertEquals('/bar/node/', make_caller_id('/bar/node'))        
    
    # restore
    if rosns:
      os.environ['ROS_NAMESPACE'] = rosns
コード例 #3
0
ファイル: nodeutil.py プロジェクト: PR2/web_interface
def topic_info(topic):
  caller_id = make_caller_id('nodeutil-%s'%os.getpid())
  master = scriptutil.get_master()

  # go through the master system state first
  try:
    state = _remote_call(master.getSystemState(caller_id))
  except socket.error:
    raise IOException("Unable to communicate with master!")
      
  pubs, subs, _ = state
  publists = [publist for t, publist in pubs if t == topic]
  sublists = [sublist for t, sublist in subs if t == topic]

  #pub_topics = _succeed(master.getPublishedTopics(caller_id, '/'))

  if publists == []:
    return {
      "error": "This topic does not appear to be published yet."
    }
  elif sublists == []: 
    return {  
        "publishers": publists[0], 
        "subscribers": [] 
    } 
  else:
    return {
      "publishers": publists[0],
      "subscribers": sublists[0]
    }
コード例 #4
0
ファイル: nodeutil.py プロジェクト: PR2/web_interface
def node_info(node):
  caller_id = make_caller_id('nodeutil-%s'%os.getpid())
  node_name = node #scriptutil.script_resolve_name(caller_id, node)
  master = scriptutil.get_master()

  # go through the master system state first
  try:
    state = _remote_call(master.getSystemState(caller_id))
  except socket.error:
    raise Exception("Unable to communicate with master!")
      
  pubs = [t for t, l in state[0] if node_name in l]
  subs = [t for t, l in state[1] if node_name in l]
  srvs = [t for t, l in state[2] if node_name in l]  

  results = {
    "publications": pubs,
    "subscriptions": subs,
    "services": srvs
  }
  node_api = get_api_uri(master, node_name, caller_id)
  if not node_api:
    results["error"] = "cannot contact [%s]: unknown node"%node_name

  return results
コード例 #5
0
ファイル: nodeutil.py プロジェクト: promikeda/web_interface
def node_info(node):
    caller_id = make_caller_id('nodeutil-%s' % os.getpid())
    node_name = node  #scriptutil.script_resolve_name(caller_id, node)
    master = scriptutil.get_master()

    # go through the master system state first
    try:
        state = _remote_call(master.getSystemState(caller_id))
    except socket.error:
        raise Exception("Unable to communicate with master!")

    pubs = [t for t, l in state[0] if node_name in l]
    subs = [t for t, l in state[1] if node_name in l]
    srvs = [t for t, l in state[2] if node_name in l]

    results = {"publications": pubs, "subscriptions": subs, "services": srvs}
    node_api = get_api_uri(master, node_name, caller_id)
    if not node_api:
        results["error"] = "cannot contact [%s]: unknown node" % node_name

    return results
コード例 #6
0
ファイル: nodeutil.py プロジェクト: promikeda/web_interface
def topic_info(topic):
    caller_id = make_caller_id('nodeutil-%s' % os.getpid())
    master = scriptutil.get_master()

    # go through the master system state first
    try:
        state = _remote_call(master.getSystemState(caller_id))
    except socket.error:
        raise IOException("Unable to communicate with master!")

    pubs, subs, _ = state
    publists = [publist for t, publist in pubs if t == topic]
    sublists = [sublist for t, sublist in subs if t == topic]

    #pub_topics = _succeed(master.getPublishedTopics(caller_id, '/'))

    if publists == []:
        return {"error": "This topic does not appear to be published yet."}
    elif sublists == []:
        return {"publishers": publists[0], "subscribers": []}
    else:
        return {"publishers": publists[0], "subscribers": sublists[0]}
コード例 #7
0
def _get_caller_id():
    return make_caller_id('rosparam-%s'%os.getpid())
コード例 #8
0
ファイル: utils.py プロジェクト: mfocchi/robot_control
 def get_caller_id(self):
     """
     @return: caller ID for rosparam ROS client calls
     @rtype: str
     """
     return make_caller_id('rosparam-%s' % os.getpid())
コード例 #9
0
ファイル: rosparam.py プロジェクト: strawlab/ros_comm
def _get_caller_id():
    """
    @return: caller ID for rosparam ROS client calls
    @rtype: str
    """
    return make_caller_id("rosparam-%s" % os.getpid())
コード例 #10
0
def _get_caller_id():
    return make_caller_id('%s-%s' % (PKG, os.getpid()))