Carma-platform v4.2.0
CARMA Platform is built on robot operating system (ROS) and utilizes open source software (OSS) that enables Cooperative Driving Automation (CDA) features to allow Automated Driving Systems to interact and cooperate with infrastructure and other vehicles through communication.
|
Variables | |
float | new_lat_0 = 0.0 |
float | new_lon_0 = 0.0 |
float | rotate_lat = 0.0 |
float | rotate_lon = 0.0 |
float | rotation_deg = 0.0 |
theta_rad = math.radians(rotation_deg) | |
parser = argparse.ArgumentParser(description="Relocate and rotate OSM map geometry around a new reference point.") | |
help | |
args = parser.parse_args() | |
tree = etree.parse(args.input_file) | |
root = tree.getroot() | |
geo_ref_elem = root.find("geoReference") | |
old_proj_str = geo_ref_elem.text.strip() | |
string | new_proj_str = f"+proj=tmerc +lat_0={new_lat_0} +lon_0={new_lon_0} +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm96_15.gtx +vunits=m +no_defs" |
crs_wgs84 = CRS.from_epsg(4326) | |
crs_old = CRS.from_proj4(old_proj_str) | |
crs_new = CRS.from_proj4(new_proj_str) | |
to_old_xy = Transformer.from_crs(crs_wgs84, crs_old, always_xy=True) | |
to_new_latlon = Transformer.from_crs(crs_new, crs_wgs84, always_xy=True) | |
text | |
xs_old | |
ys_old | |
lat = float(node.get("lat")) | |
lon = float(node.get("lon")) | |
x_old | |
y_old | |
cx_old = np.mean(xs_old) | |
cy_old = np.mean(ys_old) | |
to_new_xy = Transformer.from_crs(crs_wgs84, crs_new, always_xy=True) | |
rotate_x | |
rotate_y | |
offset_x = rotate_x - cx_old | |
offset_y = rotate_y - cy_old | |
x = xs_old[i] + offset_x | |
y = ys_old[i] + offset_y | |
x_rel | |
y_rel | |
x_rot = x_rel * math.cos(theta_rad) - y_rel * math.sin(theta_rad) | |
y_rot = x_rel * math.sin(theta_rad) + y_rel * math.cos(theta_rad) | |
new_lon | |
new_lat | |
output_file | |
pretty_print | |
True | |
xml_declaration | |
encoding | |
This script relocates and optionally rotates an OpenStreetMap (OSM) file that uses a custom geoReference. It's useful when you want to: - Move a local map to a new geographic location. - Preserve geometry, scale, and layout. - Rotate the map around its origin (for alignment or testing). --- Steps: 1. Read the input OSM XML file. 2. Extract the original geoReference (a Transverse Mercator projection centered at some latitude/longitude). 3. Convert each nodes lat/lon to projected (X, Y) coordinates using the original projection. 4. Apply a 2D rotation (optional) around the local origin (0, 0). 5. Transform the rotated (X, Y) into new lat/lon coordinates using a new projection centered at a new location. 6. Update the <geoReference> tag to reflect the new center. 7. Save the updated OSM XML file with transformed coordinates. --- Inputs: 1- input_file.osm: An OSM XML file that: - Contains a <geoReference> string using +proj=tmerc - Has <node> elements with lat and lon attributes 2- output_file.osm: The transformed OSM map name that: - All node positions have been relocated and optionally rotated - The <geoReference> tag is updated to match the new map center - The map geometry is preserved in relative terms but relocated globally --- Parameters to adjust to transform: - rotation_deg: Rotation angle in degrees (positive = counter-clockwise) - new_lat_0, new_lon_0: New center location in geographic coordinates (latitude, longitude) -- Dependency: pip install lxml pyproj -- how to run the script: python osm_transform.py suntrax.osm suntrax_transformed.osm
osm_transform.args = parser.parse_args() |
Definition at line 73 of file osm_transform.py.
osm_transform.crs_new = CRS.from_proj4(new_proj_str) |
Definition at line 96 of file osm_transform.py.
osm_transform.crs_old = CRS.from_proj4(old_proj_str) |
Definition at line 95 of file osm_transform.py.
osm_transform.crs_wgs84 = CRS.from_epsg(4326) |
Definition at line 94 of file osm_transform.py.
osm_transform.cx_old = np.mean(xs_old) |
Definition at line 117 of file osm_transform.py.
osm_transform.cy_old = np.mean(ys_old) |
Definition at line 118 of file osm_transform.py.
osm_transform.encoding |
Definition at line 152 of file osm_transform.py.
osm_transform.geo_ref_elem = root.find("geoReference") |
Definition at line 80 of file osm_transform.py.
osm_transform.help |
Definition at line 71 of file osm_transform.py.
osm_transform.lat = float(node.get("lat")) |
Definition at line 111 of file osm_transform.py.
Referenced by gnss_to_map_convertor::GNSSToMapConvertor.poseFromGnss(), and carma_cloud_client::CarmaCloudClient.XMLconversion().
osm_transform.lon = float(node.get("lon")) |
Definition at line 112 of file osm_transform.py.
Referenced by gnss_to_map_convertor::GNSSToMapConvertor.poseFromGnss().
osm_transform.new_lat |
Definition at line 141 of file osm_transform.py.
float osm_transform.new_lat_0 = 0.0 |
Definition at line 58 of file osm_transform.py.
osm_transform.new_lon |
Definition at line 141 of file osm_transform.py.
float osm_transform.new_lon_0 = 0.0 |
Definition at line 59 of file osm_transform.py.
string osm_transform.new_proj_str = f"+proj=tmerc +lat_0={new_lat_0} +lon_0={new_lon_0} +k=1 +x_0=0 +y_0=0 +datum=WGS84 +units=m +geoidgrids=egm96_15.gtx +vunits=m +no_defs" |
Definition at line 90 of file osm_transform.py.
Definition at line 125 of file osm_transform.py.
Definition at line 126 of file osm_transform.py.
osm_transform.old_proj_str = geo_ref_elem.text.strip() |
Definition at line 85 of file osm_transform.py.
osm_transform.output_file |
Definition at line 152 of file osm_transform.py.
osm_transform.parser = argparse.ArgumentParser(description="Relocate and rotate OSM map geometry around a new reference point.") |
Definition at line 70 of file osm_transform.py.
osm_transform.pretty_print |
Definition at line 152 of file osm_transform.py.
osm_transform.root = tree.getroot() |
Definition at line 77 of file osm_transform.py.
Referenced by arbitrator::TreePlanner.generate_plan().
float osm_transform.rotate_lat = 0.0 |
Definition at line 61 of file osm_transform.py.
float osm_transform.rotate_lon = 0.0 |
Definition at line 62 of file osm_transform.py.
osm_transform.rotate_x |
Definition at line 122 of file osm_transform.py.
osm_transform.rotate_y |
Definition at line 122 of file osm_transform.py.
float osm_transform.rotation_deg = 0.0 |
Definition at line 65 of file osm_transform.py.
osm_transform.text |
Definition at line 104 of file osm_transform.py.
osm_transform.theta_rad = math.radians(rotation_deg) |
Definition at line 67 of file osm_transform.py.
Definition at line 100 of file osm_transform.py.
Definition at line 121 of file osm_transform.py.
Definition at line 99 of file osm_transform.py.
osm_transform.tree = etree.parse(args.input_file) |
Definition at line 76 of file osm_transform.py.
Referenced by carma_cloud_client::CarmaCloudClient.parse_detail(), carma_cloud_client::CarmaCloudClient.parse_geometry(), carma_cloud_client::CarmaCloudClient.parse_package(), carma_cloud_client::CarmaCloudClient.parse_params(), carma_cloud_client::CarmaCloudClient.parse_schedule(), and carma_cloud_client::CarmaCloudClient.parseTCMXML().
osm_transform.True |
Definition at line 152 of file osm_transform.py.
Definition at line 130 of file osm_transform.py.
osm_transform.x_old |
Definition at line 113 of file osm_transform.py.
osm_transform.x_rel |
Definition at line 134 of file osm_transform.py.
Definition at line 135 of file osm_transform.py.
osm_transform.xml_declaration |
Definition at line 152 of file osm_transform.py.
osm_transform.xs_old |
Definition at line 109 of file osm_transform.py.
Definition at line 131 of file osm_transform.py.
osm_transform.y_old |
Definition at line 113 of file osm_transform.py.
osm_transform.y_rel |
Definition at line 134 of file osm_transform.py.
Definition at line 136 of file osm_transform.py.
osm_transform.ys_old |
Definition at line 109 of file osm_transform.py.