Commit c198abeb authored by Oleg Dzhimiev's avatar Oleg Dzhimiev
Browse files

some changes

parent 71134888
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
[Dolphin]
PreviewsShown=true
Timestamp=2018,12,12,15,36,33
SortRole=date
Timestamp=2018,12,13,15,55,15
Version=3
ViewMode=1
+1 −1
Original line number Diff line number Diff line
@@ -9,7 +9,7 @@ import ros2_config
rclpy.init()
node = rclpy.create_node('some_client_node')

cli = node.create_client(StrReqStrRes, 'master/cmd_all')
cli = node.create_client(StrReqStrRes, 'n000e64101698_master/cmd')

wcnt = 0
while not cli.wait_for_service(timeout_sec=1.0):
+15 −28
Original line number Diff line number Diff line
@@ -4,47 +4,34 @@ import os
import re
import xml.etree.ElementTree as ET

def is_unique_name(a,name):
  for i in a:
    if i['name']==name:
      return False
  return True
NODEPREFIX = 'n'

# get function
def get(f="ros2_config.xml"):

  cfg = []
  cfg = {}

  prefix = "cam_"
  mac = get_mac(capitalize=False)
  name = prefix+mac

  role = "unknown"
  mac = get_mac(last_three_octets=False,capitalize=False)
  cfg['self'] = NODEPREFIX+mac
  cfg['role'] = None

  if os.path.isfile(f):

    e = ET.parse(f).getroot()

    tmp = e.find('prefix')
    tmp = e.find('self')
    if tmp!=None:
      name = tmp.text+mac

    tmp = e.find('role')
      tmp = tmp.get('role')
      if tmp!=None:
      role = tmp.text

    # self goes first
    cfg.append({'name':name,
                'role':role})
        cfg['role'] = tmp

    # drop non-unique names
    for s in e.findall('node'):
    cfg['slaves'] = {}
    for s in e.findall('slave'):

      tmp_name = s.get('name')
      tmp_role = s.get('role')
      tmp_name = s.get('class')
      tmp_mac  = s.get('id')

      if is_unique_name(cfg,tmp_name):
        cfg.append({'name': tmp_name,
                    'role': tmp_role})
      cfg['slaves'][tmp_name] = tmp_mac
      # will not overwrite role for non-unique nodes

  return cfg
+26 −2
Original line number Diff line number Diff line
<?xml version="1.0" standalone="yes"?>
<ros2>
  <prefix>cam_</prefix>
  <role>not_master</role>
  <self role='' />
</ros2>
<!--
    <self> - info for this camera's node

      attrs:
        'role' - master or any string for not master
        'system' - not used, TBA

      example:

        <self role='' />

    <node> - info of other nodes, so this node will know other nodes 'by name'

      attrs:
        'class' - class TODO: allow multiple classes separated by comma or space
        'id'    - other node id - when composing - have to know prefix and mac

      example:

        <node class='left'  id='n000e64101698'/>


    prefixes are used because nodes names must start from a letter.

-->
 No newline at end of file
+3 −1
Original line number Diff line number Diff line
@@ -5,7 +5,9 @@ import ros2_config

cfg = ros2_config.get()

if   cfg[0]['role']=='master':
print(cfg)

if   cfg['role']=='master':
  subprocess.Popen(['python3','ros2_master.py'])

subprocess.Popen(['python3','ros2_slave.py'])
Loading