This repository has been archived by the owner on Sep 16, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
ament_python
: Port to ROS2, part 1: build #3 Errata from porting the build setup #4Launch architecture
There was an RPC server for communication between
scenario_runner
andplanning_simulator_launcher
based on a package that is not available in ROS2 anymore. Luckily, with the ROS2 Python launch API, a simpler design is possible that doesn't require the RPC server anymore.Previously, there was a script,
scenario_roslaunch_server.py
, that launched thescenario_runner.launch
launch file. That script listened on a server for calls made from withinscenario_runner
, most importantly a "terminate" call which would stop the launch file execution. This "terminate" command was used by thescenario_runner
to stop all the currently running nodes (instead of just exiting, which would only stop itself), and byscenario_roslaunch_server.py
when a timeout on the simulation duration was reached.Another function of that server was to receive updates for some variables of interest (duration and mileage of simulation), which it would then write to a log file.
We modified the launch script to exit when the
scenario_runner
node exits, eliminating the use case of "terminate" byscenario_runner
. Terminating from outside (for timeouts) can be done using standardlaunch
APIs. And logging of these variables of interest is now done directly by thescenario_runner
node itself.Launch files
npc_simulator
from launch filesPython3
I made a few easy changes to all Python files:
#!/usr/bin/env python
, it is not needed for libraries at all and even for the executable,ros2 run
takes care of selecting the interpreterflake8
and ranisort
Since I had to basically rewrite it anyway, I tried to make the code in
launch.py
idiomatic Python:pathlib
instead ofos
print(..., end='')
instead ofsys.stdout.write
.+
enumerate()
instead of creating a manual counting variableself
:self.parser
was basically a hidden argument tomap_path()
, i.e.run_all_scenario()
sets that variable before each call tomap_path()
. If someone else would callmap_path()
, it would do something unexpected or fail, so I made it an argument to the function to make it less confusingThe code in
scenario_generator.py
,scenario_parameter.py
,scenario_parser.py
andshow_result.py
have been left untouched apart from the aforementioned global changes. It is somewhat difficult to understand what they do anyway since there are no comments. But a few things to point out, in case someone needs to revisit thisscenario_id
sometimes has a different meaning in these files than inlauncher.py
which is confusingReviewer comments
scenario_database.json
and in command line arguments are required to be absolute. With relative paths, there can be confusion whether they are relative to the current working directory, thescenario_database.json
file, the script file source location or script file install location. If we want to change it later, it's relatively easy, we just need to give theabsolute_call
function the right base_dir.Open questions
scenario_database.json
or the command line? Should there be a flag to forward args to the launch file?