-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<!-- Thanks for the contribution, this is awesome. --> # PR Details ## Description This is for adding new code in carma messenger ambassador, sumo ambassador and carma messenger vehicle plugin to prepare for the carma messenger integration test ## Related GitHub Issue <!--- This project only accepts pull requests related to open GitHub issues or Jira Keys --> <!--- If suggesting a new feature or change, please discuss it in an issue first --> <!--- If fixing a bug, there should be an issue describing it with steps to reproduce --> <!--- Please DO NOT name partially fixed issues, instead open an issue specific to this fix --> <!--- Please link to the issue here: --> ## Related Jira Key <!-- e.g. CAR-123 --> ## Motivation and Context <!--- Why is this change required? What problem does it solve? --> ## How Has This Been Tested? <!--- Please describe in detail how you tested your changes. --> <!--- Include details of your testing environment, and the tests you ran to --> <!--- see how your change affects other areas of the code, etc. --> ## Types of changes <!--- What types of changes does your code introduce? Put an `x` in all the boxes that apply: --> - [x] Defect fix (non-breaking change that fixes an issue) - [x] New feature (non-breaking change that adds functionality) - [ ] Breaking change (fix or feature that cause existing functionality to change) ## Checklist: <!--- Go over all the following points, and put an `x` in all the boxes that apply. --> <!--- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> - [ ] I have added any new packages to the sonar-scanner.properties file - [ ] My change requires a change to the documentation. - [ ] I have updated the documentation accordingly. - [ ] I have read the [**CONTRIBUTING**](https://github.com/usdot-fhwa-stol/carma-platform/blob/develop/Contributing.md) document. - [ ] I have added tests to cover my changes. - [x] All new and existing tests passed.
- Loading branch information
Showing
50 changed files
with
1,972 additions
and
296 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
This folder is for plugin logs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
# Copyright (C) 2022 LEIDOS. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
# use this file except in compliance with the License. You may obtain a copy of | ||
# the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
# License for the specific language governing permissions and limitations under | ||
# the License. | ||
|
||
from sumo_connector import SumoConnector | ||
|
||
import configparser | ||
|
||
class MoveOverLaw: | ||
|
||
def __init__(self, sumo_connector, veh_id): | ||
|
||
config = configparser.ConfigParser() | ||
config.read('resources/move_over_law_cfg.ini') | ||
self._closure_uptrack = config.get('Settings', 'closure_uptrack') | ||
self._closure_downtrack = config.get('Settings', 'closure_downtrack') | ||
self._target_veh_id = config.get('Settings', 'target_id') | ||
self._veh_id = veh_id | ||
self._min_gap = config.get('Settings', 'min_gap') | ||
self._advisory_speed_limit = config.get('Settings', 'advisory_speed_limit') | ||
self._stop_route = config.get('Settings', 'stop_route') | ||
self._stop_pos = config.get('Settings', 'stop_pos') | ||
self._start_lane = config.get('Settings', 'start_lane') | ||
self.sumo_connector = sumo_connector | ||
self.sumo_connector.create_stop_veh(self._target_veh_id, self._stop_pos, self._stop_route) | ||
self.first_time_two_vehicles = True | ||
|
||
def close_lane(self): | ||
#send lane closure message | ||
combined_string = self._closure_uptrack + ";" + self._closure_downtrack + ";" + self._min_gap + ";" + self._advisory_speed_limit | ||
self.sumo_connector.set_parameter(self._veh_id, 'VehicleBroadcastTrafficEvent', combined_string) | ||
|
||
def park_messenger(self): | ||
target_lane = self.sumo_connector.get_veh_lane(self._target_veh_id) | ||
target_lane_index = int(target_lane.split('_')[-1]) | ||
self.sumo_connector.move_veh_lane(self._veh_id, target_lane_index) | ||
self.sumo_connector.stop_veh(self._veh_id) | ||
return | ||
|
||
def get_closer(self): | ||
target_lane = self.sumo_connector.get_veh_lane(self._target_veh_id) | ||
lane_index = int(target_lane.split('_')[-1]) | ||
target_lane_index = lane_index+1 | ||
self.sumo_connector.move_veh_lane(self._veh_id, target_lane_index) | ||
return | ||
|
||
def move_over(self): | ||
if len(self.sumo_connector.get_veh_ids()) >=2: | ||
|
||
if self.first_time_two_vehicles: | ||
self.sumo_connector.set_veh_lane(self._veh_id, self._start_lane) | ||
self.first_time_two_vehicles = False | ||
|
||
veh_pos = self.sumo_connector.get_veh_pos(self._veh_id) | ||
target_pos = self.sumo_connector.get_veh_pos(self._target_veh_id) | ||
distance = self.sumo_connector.cal_distance(veh_pos, target_pos) | ||
print("Distance: " + str(distance)) | ||
|
||
if distance < 30: | ||
self.park_messenger() | ||
self.close_lane() | ||
elif distance < 250: | ||
self.get_closer() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
carma_messenger_vehicle_plugin/src/resources/move_over_law_cfg.ini
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
[Settings] | ||
closure_uptrack:50 | ||
closure_downtrack:50 | ||
target_id:target1 | ||
min_gap:5 | ||
advisory_speed_limit:10.0 | ||
stop_route:stop1 | ||
stop_pos:298 | ||
start_lane:-50_4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.