Skip to content

Commit

Permalink
style(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Feb 16, 2024
1 parent 550528d commit f275488
Show file tree
Hide file tree
Showing 9 changed files with 40 additions and 28 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# autoware_tools
This is a repository for keeping packages that are not needed at runtime, including packages for benchmarking, debugging, tuning, calibrating, etc.

This is a repository for keeping packages that are not needed at runtime, including packages for benchmarking, debugging, tuning, calibrating, etc.
17 changes: 4 additions & 13 deletions bag2lanelet/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,18 @@ The provided functionalities are as follows:

## Example


As an example, the process of lanelet generation based on driving trajectories from the planning simulator is performed as follows. Typically, the expectation is to use rosbag data from manual driving, rather than from the planning simulator.


Firstly, you need to run the planning_simulator following the [planning_simulator tutorial in Autoware Documentation](https://autowarefoundation.github.io/autoware-documentation/main/tutorials/ad-hoc-simulation/planning-simulation/). The process would be, install Autoawre, download the maps, run the planning_simulator, and start autonomous driving. Make sure to save the rosbag during this driving session using the following command:

Check warning on line 14 in bag2lanelet/README.md

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (Autoawre)

```sh
ros2 bag record /tf -o /tmp/bag2lanelet_sample.bag
```



<p align="center">
<img src="./image/psim-kashiwanoha-sample-map.png" alt="kashiwa" width="800">
</p>



After completing the drive, you can run the `bag2lanelet.py` script. This requires specifying the output directory, lane width and MGRS coordinates:

```sh
Expand All @@ -35,16 +29,14 @@ After completing the drive, you can run the `bag2lanelet.py` script. This requir

The map will be saved in the specified directory, following the naming convention `<date>-lanelet2_map.osm`. The map generated will appear like this. You can see the example result in [./example/lanelet2_map.osm](./example/lanelet2_map.osm).

When you relaunch the planning_simulator with the new lanelet2 map, you will see the following.
When you relaunch the planning_simulator with the new lanelet2 map, you will see the following.

<p align="center">
<img src="./image/psim-kashiwanoha-bag2lanelet-original-map.png" alt="kashiwa" width="800">
</p>


Please note that at this stage, although this map works with Autoware, the shape of the lanes will appear jagged. (Refer to the 'Limitations' section for more details.) While this is an issue that should be addressed in the future, it can currently be resolved by loading it in [Vector Map Builder](https://autowarefoundation.github.io/autoware-documentation/main/how-to-guides/integrating-autoware/creating-maps/creating-vector-map/#vector-map-builder) as follows.


Following the documentation of the [Vector Map Builder](https://autowarefoundation.github.io/autoware-documentation/main/how-to-guides/integrating-autoware/creating-maps/creating-vector-map/#vector-map-builder), import the generated Lanelet2 map. You can see the refined lane on the application.

<p align="center">
Expand All @@ -57,7 +49,6 @@ Then, Export the map. You can run the planning_simulator with the refined lanele
<img src="./image/psim-kashiwanoha-bag2lanelet-vmb-map.png" alt="kashiwa" width="800">
</p>


## Requirements

```
Expand All @@ -75,10 +66,11 @@ Check `./bag2lanelet.py --help`
```
./bag2lanelet.py /home/autoware/rosbag/sample . --width=3.0
```

or with MGRS code at Monza Track

Check warning on line 70 in bag2lanelet/README.md

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (Monza)

```
./bag2lanelet.py /home/autoware/rosbag/sample . --width=3.0 --mgrs 32TNR219517
./bag2lanelet.py /home/autoware/rosbag/sample . --width=3.0 --mgrs 32TNR219517
```

### generate trajectory file for Vector Map Builder
Expand All @@ -87,9 +79,8 @@ or with MGRS code at Monza Track
./bag2trajectory.py /home/autoware/rosbag/sample sample.csv
```


## Limitations

Here is the limitations of this package. Contributions to further improvements are more than welcome.

- Due to the low conversion accuracy from MGRS to latitude and longitude in this script, the lanes in the output lanelet.osm appear jagged. Importing and then exporting through vector_map_builder corrects these values with high accuracy.
- Due to the low conversion accuracy from MGRS to latitude and longitude in this script, the lanes in the output lanelet.osm appear jagged. Importing and then exporting through vector_map_builder corrects these values with high accuracy.
16 changes: 12 additions & 4 deletions bag2lanelet/bag2lanelet.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#!/bin/env python3
import argparse
from datetime import datetime
import os
import pathlib
from datetime import datetime

from bag2way import bag2pose, pose2line
from bag2way import bag2pose
from bag2way import pose2line
from lanelet_xml import LaneletMap


Expand Down Expand Up @@ -36,7 +37,12 @@ def main():
parser.add_argument("-l", "--width", type=float, default=2.0, help="lane width[m]")
parser.add_argument("-m", "--mgrs", default="54SUE", help="MGRS code")
parser.add_argument(
"--interval", type=float, nargs=2, default=[0.1, 2.0], help="min and max interval between tf position")
"--interval",
type=float,
nargs=2,
default=[0.1, 2.0],
help="min and max interval between tf position",
)
parser.add_argument(
"--offset", type=float, nargs=3, default=[0.0, 0.0, 0.0], help="offset[m] from base_link"
)
Expand All @@ -49,7 +55,9 @@ def main():
output_path = pathlib.Path(args.output_lanelet)

print(args)
genarate(input_path, output_path, args.width, args.mgrs, args.interval, args.offset, args.center)
genarate(

Check warning on line 58 in bag2lanelet/bag2lanelet.py

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (genarate)
input_path, output_path, args.width, args.mgrs, args.interval, args.offset, args.center
)


if __name__ == "__main__":
Expand Down
11 changes: 8 additions & 3 deletions bag2lanelet/bag2map.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
#!/bin/env python3
import argparse
from datetime import datetime
import os
import pathlib
from datetime import datetime

from bag2way import bag2point_stamped
from bag2way import bag2pose
from bag2way import pose2line
import folium
from bag2way import bag2point_stamped, bag2pose, pose2line
from lanelet_xml import LaneletMap


def genarate(input_path, output, mgrs):

Check warning on line 14 in bag2lanelet/bag2map.py

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (genarate)
point_array = bag2point_stamped(input_path, 40.0, 500.0)
m = LaneletMap(mgrs=mgrs)
latlon = [{'lat': lat, 'lon': lon} for lat, lon in [m.get_latlon(*node) for node in point_array[:, 1:4]]]
latlon = [
{"lat": lat, "lon": lon}
for lat, lon in [m.get_latlon(*node) for node in point_array[:, 1:4]]
]
t = point_array[:, 0]

f = folium.Figure(width=800, height=500)
Expand Down
2 changes: 1 addition & 1 deletion bag2lanelet/bag2trajectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import argparse
import pathlib

from bag2way import bag2pose
import numpy as np
import tf_transformations
from bag2way import bag2pose


def genarate(input_path, output_path):

Check warning on line 10 in bag2lanelet/bag2trajectory.py

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (genarate)
Expand Down
7 changes: 5 additions & 2 deletions bag2lanelet/bag2way.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
from typing import Text

import numpy as np
import tf_transformations
from rclpy.serialization import deserialize_message
from rosbag2_py import ConverterOptions, SequentialReader, StorageOptions
from rosbag2_py import ConverterOptions
from rosbag2_py import SequentialReader
from rosbag2_py import StorageOptions
from rosidl_runtime_py.utilities import get_message
import tf_transformations


def create_reader(bag_dir: str) -> SequentialReader:
Expand All @@ -22,6 +24,7 @@ def create_reader(bag_dir: str) -> SequentialReader:
reader.open(storage_options, converter_options)
return reader


# too close & outlier pose filter
def is_close_pose(p0, p1, eps, thresh):
dist = ((p0.x - p1.x) ** 2 + (p0.y - p1.y) ** 2 + (p0.z - p1.z) ** 2) ** 0.5
Expand Down
9 changes: 7 additions & 2 deletions bag2lanelet/lanelet_xml.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import xml.etree.ElementTree as ET
from xml.dom.minidom import parseString
import xml.etree.ElementTree as ET

from mgrspy import mgrs

Check warning on line 4 in bag2lanelet/lanelet_xml.py

View workflow job for this annotation

GitHub Actions / spell-check-partial

Unknown word (mgrspy)


Expand Down Expand Up @@ -27,7 +28,11 @@ def add_node(self, x, y, z):
print(mgrs_code)
latlon = mgrs.toWgs(mgrs_code)
mgrs_code = self.mgrs + ("%05d" % x)[:3] + ("%05d" % y)[:3]
node = ET.SubElement(self.root, 'node', {'id': str(self.element_num), 'lat': str(latlon[0]), 'lon': str(latlon[1])})
node = ET.SubElement(
self.root,
"node",
{"id": str(self.element_num), "lat": str(latlon[0]), "lon": str(latlon[1])},
)
tag = [
{"k": "type", "v": ""},
{"k": "subtype", "v": ""},
Expand Down
2 changes: 1 addition & 1 deletion bag2lanelet/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
transforms3d
mgrspy
mgrspy
1 change: 0 additions & 1 deletion build_depends.repos
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,3 @@ repositories:
type: git
url: https://github.com/tier4/autoware_auto_msgs.git
version: tier4/main

0 comments on commit f275488

Please sign in to comment.