Skip to content

feat(map_projection_loader): add scale_factor and remove altitude #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ std::unique_ptr<lanelet::Projector> get_lanelet2_projector(const MapProjectorInf
projector_info.map_origin.latitude, projector_info.map_origin.longitude,
projector_info.map_origin.altitude};
const lanelet::Origin origin{position};
const lanelet::projection::TransverseMercatorProjector projector{origin};
const lanelet::projection::TransverseMercatorProjector projector{
origin, projector_info.scale_factor};
return std::make_unique<lanelet::projection::TransverseMercatorProjector>(projector);
}

Expand Down
13 changes: 10 additions & 3 deletions map/autoware_map_projection_loader/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ There are three types of transformations from latitude and longitude to XYZ coor
projector_type: Local
```

※ Even if you input scale_factor, it will be overwritten to 1.0.

#### Limitation

The functionality that requires latitude and longitude will become unavailable.
Expand All @@ -52,6 +54,8 @@ vertical_datum: WGS84
mgrs_grid: 54SUE
```

※ Even if you input scale_factor, it will be overwritten to 0.9996.

#### Limitation

It cannot be used with maps that span across two or more MGRS grids. Please use it only when it falls within the scope of a single MGRS grid.
Expand All @@ -67,9 +71,10 @@ vertical_datum: WGS84
map_origin:
latitude: 35.6762 # [deg]
longitude: 139.6503 # [deg]
altitude: 0.0 # [m]
```

※ Even if you input scale_factor, it will be overwritten to 0.9996.

### Using LocalCartesian

If you want to use local cartesian WGS84, please specify the map origin as well.
Expand All @@ -83,12 +88,14 @@ vertical_datum: WGS84
map_origin:
latitude: 35.6762 # [deg]
longitude: 139.6503 # [deg]
altitude: 0.0 # [m]
```

※ Even if you input scale_factor, it will be overwritten to 1.0.

### Using TransverseMercator

If you want to use Transverse Mercator projection, please specify the map origin as well.
And specify the scale_factor of the map. If you didn't specify the scale_factor, it will be set 0.9996 as default value.

```yaml
# map_projector_info.yaml
Expand All @@ -97,7 +104,7 @@ vertical_datum: WGS84
map_origin:
latitude: 35.6762 # [deg]
longitude: 139.6503 # [deg]
altitude: 0.0 # [m]
scale_factor: 0.9996
```

## Published Topics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ autoware_map_msgs::msg::MapProjectorInfo load_info_from_yaml(const std::string &
msg.vertical_datum = data["vertical_datum"].as<std::string>();
msg.map_origin.latitude = data["map_origin"]["latitude"].as<double>();
msg.map_origin.longitude = data["map_origin"]["longitude"].as<double>();
msg.map_origin.altitude = data["map_origin"]["altitude"].as<double>();
msg.map_origin.altitude = 0.0;

} else if (msg.projector_type == autoware_map_msgs::msg::MapProjectorInfo::LOCAL) {
; // do nothing
Expand All @@ -64,6 +64,28 @@ autoware_map_msgs::msg::MapProjectorInfo load_info_from_yaml(const std::string &
"LocalCartesianUTM, "
"TransverseMercator, and local");
}

// set scale factor
if (msg.projector_type == autoware_map_msgs::msg::MapProjectorInfo::TRANSVERSE_MERCATOR) {
if (data["scale_factor"]) {
msg.scale_factor = data["scale_factor"].as<double>();
} else {
msg.scale_factor = 0.9996;
}
} else if (
msg.projector_type == autoware_map_msgs::msg::MapProjectorInfo::MGRS ||
msg.projector_type == autoware_map_msgs::msg::MapProjectorInfo::LOCAL_CARTESIAN_UTM) {
msg.scale_factor = 0.9996;
} else if (
msg.projector_type == autoware_map_msgs::msg::MapProjectorInfo::LOCAL ||
msg.projector_type == autoware_map_msgs::msg::MapProjectorInfo::LOCAL_CARTESIAN) {
msg.scale_factor = 1.0;
}

if (msg.scale_factor <= 0.0) {
throw std::runtime_error(
"Invalid scale factor. The scale factor must be a value greater than 0.");
}
return msg;
}

Expand Down
Loading