Commit 28eae785 authored by Oleg Dzhimiev's avatar Oleg Dzhimiev

initial

parent 16aa7bcb
Pipeline #838 canceled with stages
# Runs 'make', 'make install', and 'make clean' in specified subdirectories
SUBDIRS := src/init # src1
INSTALLDIRS = $(SUBDIRS:%=install-%)
CLEANDIRS = $(SUBDIRS:%=clean-%)
#TARGETDIR=$(DESTDIR)/www/pages
all: $(SUBDIRS)
@echo "make all top"
$(SUBDIRS):
$(MAKE) -C $@
install: $(INSTALLDIRS)
echo "make install top"
$(INSTALLDIRS):
$(MAKE) -C $(@:install-%=%) install
clean: $(CLEANDIRS)
@echo "make clean top"
$(CLEANDIRS):
$(MAKE) -C $(@:clean-%=%) clean
.PHONY: all install clean $(SUBDIRS) $(INSTALLDIRS) $(CLEANDIRS)
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
<storageModule moduleId="org.eclipse.cdt.core.settings">
<cconfiguration id="0.1221820363">
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="0.1221820363" moduleId="org.eclipse.cdt.core.settings" name="Default">
<externalSettings />
<extensions>
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser" />
<extension id="org.eclipse.cdt.core.GmakeErrorParser" point="org.eclipse.cdt.core.ErrorParser" />
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser" />
<extension id="org.eclipse.cdt.core.VCErrorParser" point="org.eclipse.cdt.core.ErrorParser" />
<extension id="org.eclipse.cdt.core.CWDLocator" point="org.eclipse.cdt.core.ErrorParser" />
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser" />
</extensions>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<configuration artifactName="${ProjName}" buildProperties="" description="" id="0.1221820363" name="Default" parent="org.eclipse.cdt.build.core.prefbase.cfg">
<folderInfo id="0.1221820363." name="/" resourcePath="">
<toolChain id="org.eclipse.cdt.build.core.prefbase.toolchain.1043274217" name="No ToolChain" resourceTypeBasedDiscovery="false" superClass="org.eclipse.cdt.build.core.prefbase.toolchain">
<targetPlatform id="org.eclipse.cdt.build.core.prefbase.toolchain.1043274217.1071800033" name="" />
<builder arguments="ros2-scripts" command="${workspace_loc:/ros2-scripts/scripts/run_bitbake.sh}" enableCleanBuild="false" enabledIncrementalBuild="true" id="org.eclipse.cdt.build.core.settings.default.builder.365026764" incrementalBuildTarget="-c install -f" keepEnvironmentInBuildfile="false" managedBuildOn="false" name="Gnu Make Builder" superClass="org.eclipse.cdt.build.core.settings.default.builder" />
<tool id="org.eclipse.cdt.build.core.settings.holder.libs.785882741" name="holder for library settings" superClass="org.eclipse.cdt.build.core.settings.holder.libs" />
<tool id="org.eclipse.cdt.build.core.settings.holder.982996495" name="Assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.8554647" languageId="org.eclipse.cdt.core.assembly" languageName="Assembly" sourceContentType="org.eclipse.cdt.core.asmSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType" />
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.480226500" name="GNU C++" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1347472659" languageId="org.eclipse.cdt.core.g++" languageName="GNU C++" sourceContentType="org.eclipse.cdt.core.cxxSource,org.eclipse.cdt.core.cxxHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType" />
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1686385332" name="GNU C" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.716913472" languageId="org.eclipse.cdt.core.gcc" languageName="GNU C" sourceContentType="org.eclipse.cdt.core.cSource,org.eclipse.cdt.core.cHeader" superClass="org.eclipse.cdt.build.core.settings.holder.inType" />
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.559915258" name="LLVM bytecode assembly" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1886099197" languageId="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssembly" languageName="LLVM bytecode assembly" sourceContentType="org.eclipse.cdt.managedbuilder.llvm.ui.llvmAssemblySource" superClass="org.eclipse.cdt.build.core.settings.holder.inType" />
</tool>
<tool id="org.eclipse.cdt.build.core.settings.holder.1960214219" name="UPC" superClass="org.eclipse.cdt.build.core.settings.holder">
<inputType id="org.eclipse.cdt.build.core.settings.holder.inType.1593701683" languageId="org.eclipse.cdt.core.parser.upc.upc" languageName="UPC" sourceContentType="org.eclipse.cdt.core.parser.upc.upcSource" superClass="org.eclipse.cdt.build.core.settings.holder.inType" />
</tool>
</toolChain>
</folderInfo>
<sourceEntries>
<entry flags="VALUE_WORKSPACE_PATH" kind="sourcePath" name="src" />
</sourceEntries>
</configuration>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.externalSettings" />
</cconfiguration>
</storageModule>
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
<project id="ros2-scripts.null.1071524317" name="ros2-scripts" />
</storageModule>
<storageModule moduleId="scannerConfiguration">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="" />
<scannerConfigBuildInfo instanceId="0.1221820363">
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="" />
</scannerConfigBuildInfo>
</storageModule>
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders" />
<storageModule moduleId="refreshScope" versionNumber="2">
<configuration configurationName="Default">
<resource resourceType="PROJECT" workspacePath="/ros2-scripts" />
</configuration>
</storageModule>
</cproject>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ui.externaltools.ProgramBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.debug.ui.ATTR_LAUNCH_IN_BACKGROUND" value="false"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="true"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_LOCATION" value="${workspace_loc:/ros2-scripts/scripts/run_bitbake.sh}"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_RUN_BUILD_KINDS" value="incremental,"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS" value="ros2-scripts -c target_scp -f"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ros2-scripts</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/SCP ros2-scripts to target.launch</value>
</dictionary>
<dictionary>
<key>incclean</key>
<value>true</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.python.pydev.PyDevBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
<nature>org.python.pydev.pythonNature</nature>
</natures>
</projectDescription>
[Dolphin]
PreviewsShown=true
Timestamp=2018,12,12,15,36,33
Version=3
ViewMode=1
DOCUMENTROOT=$(DESTDIR)/etc/elphel393
OWN = -o root -g root
INSTDOCS = 0644
INSTALL = install
DOCS = ros2_client.py \
ros2_config.py \
ros2_config.xml \
ros2_init.py \
ros2_master.py \
ros2_slave.py
all:
@echo "make all in src"
install:
@echo "make install in src"
$(INSTALL) $(OWN) -d $(DOCUMENTROOT)
$(INSTALL) $(OWN) -m $(INSTDOCS) $(DOCS) $(DOCUMENTROOT)
clean:
@echo "make clean in src"
#!/usr/bin/env python3
import xml.etree.ElementTree as ET
import rclpy
from elphel_interfaces.srv import StrReqStrRes
import ros2_config
rclpy.init()
node = rclpy.create_node('some_client_node')
cli = node.create_client(StrReqStrRes, 'master/cmd_all')
wcnt = 0
while not cli.wait_for_service(timeout_sec=1.0):
print('Service is not available, waiting '+str(wcnt)+'...')
wcnt += 1
req = StrReqStrRes.Request()
req.request = "wget -qO- -o /dev/null 'http://localhost/parsedit.php?immediate&TRIG'"
cli.call(req)
cli.wait_for_future()
res = cli.response.response
node.get_logger().info("cmd response:")
node.get_logger().info(res)
node.destroy_node()
rclpy.shutdown()
\ No newline at end of file
#!/usr/bin/env python3
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
# get function
def get(f="ros2_config.xml"):
cfg = []
prefix = "cam_"
mac = get_mac(capitalize=False)
name = prefix+mac
role = "unknown"
if os.path.isfile(f):
e = ET.parse(f).getroot()
tmp = e.find('prefix')
if tmp!=None:
name = tmp.text+mac
tmp = e.find('role')
if tmp!=None:
role = tmp.text
# self goes first
cfg.append({'name':name,
'role':role})
# drop non-unique names
for s in e.findall('node'):
tmp_name = s.get('name')
tmp_role = s.get('role')
if is_unique_name(cfg,tmp_name):
cfg.append({'name': tmp_name,
'role': tmp_role})
# will not overwrite role for non-unique nodes
return cfg
# get mac function
def get_mac(last_three_octets=True, keep_colons=False, capitalize=True):
mac = "00:00:00:00:00:00"
for root, dirs, files in os.walk("/sys/class/net/"):
for name in dirs:
# enp or wlp will work for linux pc for testing
if re.match('(eth|enp|wlp)',name):
fname = os.path.join(root,name,'address')
#print(fname)
with open(fname, 'r') as content_file:
mac = content_file.read().strip()
break
if last_three_octets:
mac = mac[-8:]
if not keep_colons:
mac = re.sub(':','',mac)
if capitalize:
mac = mac.upper()
return mac
# MAIN
if __name__ == "__main__":
# Test 1
mac = get_mac()
print(mac)
# Test 2
mac = get_mac(last_three_octets=False,keep_colons=True,capitalize=False)
print(mac)
\ No newline at end of file
<?xml version="1.0" standalone="yes"?>
<ros2>
<prefix>cam_</prefix>
<role>master</role>
<node name='cam_101698' role='left'/>
<node name='cam_1467cd' role='pc'/>
</ros2>
#!/usr/bin/env python3
import subprocess
import ros2_config
cfg = ros2_config.get()
if cfg[0]['role']=='master':
subprocess.Popen(['python3','ros2_master.py'])
subprocess.Popen(['python3','ros2_slave.py'])
#!/usr/bin/env python3
import asyncio
import xml.etree.ElementTree as ET
import rclpy
from elphel_interfaces.srv import StrReqStrRes
import ros2_config
TIMEOUT = 5
# master callbacks
def signup_callback(req,res):
name = req.request
print('Sign up from '+name)
if name in clients:
print('Slave name is not unique. So sad.')
else:
clients.append(name)
print('List of registered slaves: '+str(clients))
res.response = name
return res
# async coroutine for cmdall_callback
async def pass_cmd(target,cmd):
node = rclpy.create_node(target+'_client')
cli = node.create_client(StrReqStrRes,target+'/cmd')
wcnt = 0
while not cli.wait_for_service(timeout_sec=1.0):
print('Service is not available, waiting '+str(wcnt)+'...')
wcnt += 1
if wcnt==TIMEOUT:
break
req = StrReqStrRes.Request()
req.request = cmd
cli.call(req)
cli.wait_for_future()
cmdres = cli.response.response
return cmdres
# callback for broadcast commands
def cmdall_callback(req,res):
cmd = req.request
tasks = [pass_cmd(c,cmd) for c in clients]
results = event_loop.run_until_complete(asyncio.gather(*tasks))
print(results)
res.response = '\n'.join(results)
return res
# global
clients = []
cfg = ros2_config.get()
nodename = cfg[0]['name']
for i in cfg:
clients.append(i['name'])
rclpy.init()
node = rclpy.create_node(nodename+"_master")
event_loop = asyncio.get_event_loop()
print("Starting master services:")
#print(" master/signup")
#s1 = node.create_service(StrReqStrRes, 'master/signup', signup_callback)
print(" master/cmd_all")
s2 = node.create_service(StrReqStrRes, 'master/cmd_all', cmdall_callback)
rclpy.spin(node)
# Destroy the node explicitly
# (optional - Done automatically when node is garbage collected)
node.destroy_node()
rclpy.shutdown()
event_loop.close()
#!/usr/bin/env python3
import subprocess
import xml.etree.ElementTree as ET
import rclpy
from elphel_interfaces.srv import StrReqStrRes
import ros2_config
TIMEOUT = 5
# slave callbacks
def cmd_callback(req,res):
cmd = req.request
# call to localhost here, get response and send it back
try:
output = subprocess.check_output(cmd,shell=True)
except subprocess.CalledProcessError:
output = "<error>-1</error>"
res.response = '<cmd><node>'+nodename+'</node><status>'+str(output)+'</status></cmd>'
return res
# global
cfg = ros2_config.get()
nodename = cfg[0]['name']
rclpy.init()
node = rclpy.create_node(nodename)
# now start cmd service
print("Starting slave services:")
print(" "+nodename+'/cmd')
s3 = node.create_service(StrReqStrRes, nodename+'/cmd', cmd_callback)
rclpy.spin(node)
# Destroy the node explicitly
# (optional - Done automatically when node is garbage collected)
node.destroy_node()
rclpy.shutdown()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment