Skip to content

Commit

Permalink
Merge branch 'kinetic-devel' into node-name
Browse files Browse the repository at this point in the history
  • Loading branch information
knorth55 authored Jul 29, 2022
2 parents 356ff69 + 7b780db commit 53995f0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 10 deletions.
16 changes: 13 additions & 3 deletions launch/app_manager.launch
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@
<!-- respawn -->
<arg name="respawn" default="false" doc="respawn app_manager"/>

<!-- app_manager options -->
<arg name="enable_app_replacement" default="true"
doc="Enable app replacement by running another app, or not" />
<arg name="enable_topic_remapping" default="true"
doc="Enable name remapping of topic written in interface to app_manager namespace , or not" />

<!-- internal use -->
<arg name="applist_args" default="--applist $(arg applist)" if="$(arg use_applist)"/>
<arg name="applist_args" default="" unless="$(arg use_applist)"/>
Expand All @@ -41,8 +47,12 @@
<node pkg="app_manager" type="app_manager" name="$(arg manager_node_name)"
args="$(arg applist_args) $(arg robot_name_args) $(arg robot_type_args)"
output="screen" respawn="$(arg respawn)">
<param name="interface_master" value="http://$(arg master_address):$(arg master_port)"/>
<param name="sigint_timeout" value="$(arg sigint_timeout)"/>
<param name="sigterm_timeout" value="$(arg sigterm_timeout)"/>
<rosparam subst_value="true">
interface_master: http://$(arg master_address):$(arg master_port)
enable_app_replacement: $(arg enable_app_replacement)
enable_topic_remapping: $(arg enable_topic_remapping)
sigint_timeout: $(arg sigint_timeout)
sigterm_timeout: $(arg sigterm_timeout)
</rosparam>
</node>
</launch>
2 changes: 2 additions & 0 deletions scripts/app_manager
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,12 @@ def main():
sys.exit(1)

enable_app_replacement = rospy.get_param('~enable_app_replacement', True)
enable_topic_remapping = rospy.get_param('~enable_topic_remapping', True)

am = app_manager.AppManager(
robot_name, interface_master, app_list, exchange, plugins,
enable_app_replacement=enable_app_replacement,
enable_topic_remapping=enable_topic_remapping,
sigint_timeout=sigint_timeout, sigterm_timeout=sigterm_timeout)

rospy.on_shutdown(am.shutdown)
Expand Down
20 changes: 13 additions & 7 deletions src/app_manager/app_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ class AppManager(object):
def __init__(
self, robot_name, interface_master, app_list,
exchange, plugins=None, enable_app_replacement=True,
enable_topic_remapping=True,
sigint_timeout=15.0, sigterm_timeout=2.0,
):
self._robot_name = robot_name
Expand All @@ -134,6 +135,7 @@ def __init__(
self._exchange = exchange
self._plugins = plugins
self._enable_app_replacement = enable_app_replacement
self._enable_topic_remapping = enable_topic_remapping
self._sigint_timeout = sigint_timeout
self._sigterm_timeout = sigterm_timeout

Expand Down Expand Up @@ -442,11 +444,12 @@ def handle_start_app(self, req):
nodes.extend(self._launch.config.nodes)
if app.run:
nodes.append(app.run)
for N in nodes:
for t in app.interface.published_topics.keys():
N.remap_args.append((t, self._app_interface + '/' + t))
for t in app.interface.subscribed_topics.keys():
N.remap_args.append((t, self._app_interface + '/' + t))
if self._enable_topic_remapping:
for N in self._launch.config.nodes:
for t in app.interface.published_topics.keys():
N.remap_args.append((t, self._app_interface + '/' + t))
for t in app.interface.subscribed_topics.keys():
N.remap_args.append((t, self._app_interface + '/' + t))

# run plugin modules first
self._current_plugin_processes = []
Expand Down Expand Up @@ -514,8 +517,11 @@ def handle_start_app(self, req):
if app.timeout is not None:
self._start_time = rospy.Time.now()

fp = [self._app_interface + '/' + x for x in app.interface.subscribed_topics.keys()]
lp = [self._app_interface + '/' + x for x in app.interface.published_topics.keys()]
fp = [x for x in app.interface.subscribed_topics.keys()]
lp = [x for x in app.interface.published_topics.keys()]
if self._enable_topic_remapping:
fp = [self._app_interface + '/' + x for x in fp]
lp = [self._app_interface + '/' + x for x in lp]

self._interface_sync = MasterSync(self._interface_master, foreign_pub_names=fp, local_pub_names=lp)

Expand Down

0 comments on commit 53995f0

Please sign in to comment.