-
Notifications
You must be signed in to change notification settings - Fork 13
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
CARMA Messenger Integration Test #231
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
6c2f4b0
Add a scenario for CARMA Messenger Integration
chengyuan0124 694c72c
Update Town04.sumocfg
chengyuan0124 86caed5
Update scenario_config.json
chengyuan0124 f539912
test updates
EricChen-Lei 2c72e0a
CARMA vehicle runnable
EricChen-Lei ad5bd90
fix car disappear issue
EricChen-Lei 01327a5
Update log and parameter name for getting traffic event
chengyuan0124 6abaa63
Update CommonInstanceManager.java
chengyuan0124 b847897
Revert "Update log and parameter name for getting traffic event"
chengyuan0124 da1b989
Revert "Update CommonInstanceManager.java"
chengyuan0124 daba826
fix vehicle pos issue
EricChen-Lei f622f48
proj fixed
EricChen-Lei 5e16614
update lane
EricChen-Lei 56151bb
change distance
EricChen-Lei 680726c
Update config setting for msger vehicle
chengyuan0124 e3fb4a0
Update msger_veh_cfg.json
chengyuan0124 ff27387
changes add into config
EricChen-Lei File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
10 changes: 6 additions & 4 deletions
10
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 |
---|---|---|
@@ -1,9 +1,11 @@ | ||
[Settings] | ||
closure_uptrack:50 | ||
closure_downtrack:50 | ||
closure_uptrack:5 | ||
closure_downtrack:5 | ||
target_id:target1 | ||
min_gap:5 | ||
advisory_speed_limit:10.0 | ||
stop_route:stop1 | ||
stop_pos:298 | ||
start_lane:-50_4 | ||
stop_pos:78 | ||
start_lane:-43_4 | ||
stop_lane:2 | ||
stop_dist_msger:70 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,7 @@ | |
import os | ||
import logging | ||
import math | ||
import time | ||
|
||
if 'SUMO_HOME' in os.environ: | ||
tools_path = os.path.join(os.environ['SUMO_HOME'], 'tools') | ||
|
@@ -209,17 +210,26 @@ def cal_distance(self, pos_1, pos_2): | |
""" | ||
try: | ||
distance = math.sqrt((pos_1[0] - pos_2[0])**2 + (pos_1[1] - pos_2[1])**2) | ||
logging.debug("Distance to target: " + str(distance)) | ||
return distance | ||
except Exception as e: | ||
logging.error(f"Failed to calculate vehicle distance ") | ||
raise | ||
|
||
def stop_veh(self, veh_id): | ||
def stop_veh(self, veh_id, stop_lane, stop_dist): | ||
""" | ||
stops vehicle at current place in SUMO | ||
""" | ||
try: | ||
traci.vehicle.setSpeed(veh_id, 0) | ||
traci.vehicle.setStop( | ||
vehID=veh_id, # Vehicle ID | ||
edgeID=traci.vehicle.getRoadID(veh_id), # Edge ID where the vehicle stops | ||
pos=70, # Position (meters) on the edge | ||
laneIndex=stop_lane, # Lane index (e.g., 0 for the first lane) | ||
duration=stop_dist, # Duration (in seconds) the vehicle stays stopped | ||
flags=0 # Flags (optional, can be left as 0) | ||
) | ||
|
||
except Exception as e: | ||
logging.error(f"Failed to stop vehicle for vehicle ID '{veh_id}': {e}") | ||
|
@@ -257,7 +267,7 @@ def get_veh_pos(self, veh_id): | |
|
||
def create_stop_veh(self, veh_id, end_pos, stop_route): | ||
try: | ||
traci.vehicle.add(vehID = veh_id, routeID=stop_route, typeID="car", depart=0, departPos=end_pos) | ||
traci.vehicle.add(vehID = veh_id, routeID=stop_route, typeID="car", depart=0, departPos=end_pos, departLane='2') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as comment above re hard-coding |
||
traci.vehicle.setSpeed(veh_id, 0) | ||
except Exception as e: | ||
logging.error(f"Failed to create stopped vehicle for vehicle ID '{veh_id}': {e}") | ||
|
Binary file added
BIN
+410 KB
...tion/bundle/src/assembly/resources/scenarios/Town04_carma_messenger/application/Town04.db
Binary file not shown.
6 changes: 6 additions & 0 deletions
6
co-simulation/bundle/src/assembly/resources/scenarios/Town04_carma_messenger/carla/bridge.sh
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,6 @@ | ||
#!/bin/bash | ||
|
||
#x-terminal-emulator | ||
cd /opt/carma-simulation/bridge | ||
|
||
x-terminal-emulator -e python3.7 carla_mosaic_bridge.py --bridge-server-port 8913 -m Town04 /opt/carma-simulation/scenarios/Town04_carma_messenger/sumo/Town04.net.xml --step-length 0.1 --tls-manager EVC |
7 changes: 7 additions & 0 deletions
7
...on/bundle/src/assembly/resources/scenarios/Town04_carma_messenger/carla/carla_config.json
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,7 @@ | ||
{ | ||
"updateInterval": 100, | ||
"carlaUE4Path": "/opt/carla/", | ||
"bridgePath": "/opt/carma-simulation/scenarios/Town04_carma_messenger/carla; bridge.sh", | ||
"carlaConnectionPort": 8913, | ||
"carlaCDASimAdapterUrl":"http://172.2.0.5:8000/RPC2" | ||
} |
3 changes: 3 additions & 0 deletions
3
...c/assembly/resources/scenarios/Town04_carma_messenger/carma-cloud/carma-cloud_config.json
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,3 @@ | ||
{ | ||
"updateInterval": 100 | ||
} |
4 changes: 4 additions & 0 deletions
4
...on/bundle/src/assembly/resources/scenarios/Town04_carma_messenger/carma/carma_config.json
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,4 @@ | ||
{ | ||
"updateInterval": 100, | ||
"carmaVehicles": [] | ||
} |
3 changes: 3 additions & 0 deletions
3
...mbly/resources/scenarios/Town04_carma_messenger/infrastructure/infrastructure_config.json
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,3 @@ | ||
{ | ||
"updateInterval": 100 | ||
} |
6 changes: 6 additions & 0 deletions
6
...undle/src/assembly/resources/scenarios/Town04_carma_messenger/mapping/mapping_config.json
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,6 @@ | ||
{ | ||
"prototypes": [], | ||
"chargingStations": [], | ||
"vehicles": [ | ||
] | ||
} |
20 changes: 20 additions & 0 deletions
20
...lation/bundle/src/assembly/resources/scenarios/Town04_carma_messenger/ns3/ns3_config.json
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,20 @@ | ||
{ | ||
"messages": { | ||
"destinationType": { | ||
"AD_HOC_GEOCAST": true, | ||
"AD_HOC_TOPOCAST": false, | ||
"CELL_GEOCAST": false, | ||
"CELL_GEOCAST_MBMS": false, | ||
"CELL_TOPOCAST": false | ||
}, | ||
"destinationAddress": { | ||
"ipv4UnicastAddress": false, | ||
"ipv4BroadcastAddress": true, | ||
"ipv4AnycastAddress" : false | ||
}, | ||
"protocolType": { | ||
"UDP": true, | ||
"TCP": false | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
...undle/src/assembly/resources/scenarios/Town04_carma_messenger/ns3/ns3_federate_config.xml
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,93 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<ns3> | ||
<LogLevel> | ||
<!-- for name, refer to corresponding ns3 model --> | ||
<!-- possible level values: error warn debug info function logic all * --> | ||
<!-- including higher levels: level_error level_warn level_debug level_info level_function level_logic level_all ** --> | ||
<!-- possible prefix values: func time node level prefix_func prefix_time prefix_node prefix_level prefix_all --> | ||
<component name="*" value="prefix_level|prefix_time"/> | ||
|
||
<component name="MosaicStarter" value="warn|error|debug|info"/> | ||
<component name="MosaicSimulatorImpl" value="warn|error|debug|info"/> | ||
<component name="MosaicNs3Server" value="warn|error|debug|info"/> | ||
<component name="MosaicNodeManager" value="warn|error|debug|info"/> | ||
<component name="MosaicProxyApp" value="warn|error|debug|info|function|func"/> | ||
|
||
<component name="UdpSocketImpl" value="warn|error|info"/> | ||
<component name="UdpL4Protocol" value="warn|error|info"/> | ||
<component name="Ipv4L3Protocol" value="warn|error|info"/> | ||
<component name="Ipv4Interface" value="warn|error|info"/> | ||
<component name="TrafficControlLayer" value="warn|error|info"/> | ||
|
||
<component name="PropagationLossModel" value="warn|error|info"/> | ||
<component name="YansWifiPhy" value="warn|error|info"/> | ||
<component name="WaveNetDevice" value="warn|error|info"/> | ||
<component name="YansWifiChannel" value="warn|error|info"/> | ||
<component name="InterferenceHelper" value="warn|error|info"/> | ||
<!-- List can be extendy by other components to set logging for --> | ||
</LogLevel> | ||
|
||
<!-- Mosaic Federate settings --> | ||
<default name="ns3::MosaicProxyApp::Port" value="8010"/> | ||
<default name="ns3::MosaicNodeManager::DelayModel" value="ns3::ConstantSpeedPropagationDelayModel"/> | ||
<default name="ns3::MosaicNodeManager::LossModel" value="ns3::FriisPropagationLossModel"/> | ||
|
||
|
||
<!-- NS3 model settings --> | ||
<default name="ns3::RandomPropagationDelayModel::Variable" value="ns3::UniformRandomVariable"/> | ||
<default name="ns3::ConstantSpeedPropagationDelayModel::Speed" value="2.99792e+08"/> | ||
|
||
<default name="ns3::RandomPropagationLossModel::Variable" value="ns3::ConstantRandomVariable[Constant=1.0]"/> | ||
|
||
<default name="ns3::FriisPropagationLossModel::Frequency" value="5900000000"/> | ||
<default name="ns3::FriisPropagationLossModel::SystemLoss" value="1"/> | ||
<default name="ns3::FriisPropagationLossModel::MinLoss" value="0"/> | ||
|
||
<default name="ns3::TwoRayGroundPropagationLossModel::Frequency" value="5900000000"/> | ||
<default name="ns3::TwoRayGroundPropagationLossModel::SystemLoss" value="1"/> | ||
<default name="ns3::TwoRayGroundPropagationLossModel::MinDistance" value="1"/> | ||
<default name="ns3::TwoRayGroundPropagationLossModel::HeightAboveZ" value="2"/> | ||
|
||
<default name="ns3::LogDistancePropagationLossModel::Exponent" value="2.0"/> | ||
<default name="ns3::LogDistancePropagationLossModel::ReferenceDistance" value="1"/> | ||
<default name="ns3::LogDistancePropagationLossModel::ReferenceLoss" value="47.85704"/> | ||
|
||
<default name="ns3::WifiPhy::EnergyDetectionThreshold" value="-81.02"/> | ||
<default name="ns3::WifiPhy::CcaMode1Threshold" value="-99.0"/> | ||
<default name="ns3::WifiPhy::TxGain" value="0.0"/> | ||
<default name="ns3::WifiPhy::RxGain" value="0.0"/> | ||
<default name="ns3::WifiPhy::TxPowerLevels" value="1"/> | ||
<default name="ns3::WifiPhy::TxPowerEnd" value="17"/> | ||
<default name="ns3::WifiPhy::TxPowerStart" value="17"/> | ||
<default name="ns3::WifiPhy::RxNoiseFigure" value="0"/> | ||
<default name="ns3::WifiPhy::ChannelSwitchDelay" value="+250000.0ns"/> | ||
<default name="ns3::WifiPhy::ChannelNumber" value="178"/> | ||
<default name="ns3::WifiPhy::Frequency" value="5900"/> | ||
<default name="ns3::WifiPhy::Antennas" value="1"/> | ||
<default name="ns3::WifiPhy::ShortGuardEnabled" value="false"/> | ||
<default name="ns3::WifiPhy::LdpcEnabled" value="false"/> | ||
<default name="ns3::WifiPhy::STBCEnabled" value="false"/> | ||
<default name="ns3::WifiPhy::GreenfieldEnabled" value="false"/> | ||
<default name="ns3::WifiPhy::ShortPlcpPreambleSupported" value="false"/> | ||
<default name="ns3::WifiPhy::ChannelWidth" value="10"/> | ||
|
||
<default name="ns3::ConstantRateWifiManager::DataMode" value="OfdmRate6Mbps"/> | ||
<default name="ns3::ConstantRateWifiManager::ControlMode" value="OfdmRate6Mbps"/> | ||
|
||
<default name="ns3::QueueBase::MaxPackets" value="400"/> | ||
<default name="ns3::WifiMacQueue::MaxDelay" value="+500000000.0ns"/> | ||
<default name="ns3::WifiNetDevice::Mtu" value="2296"/> | ||
|
||
<default name="ns3::WifiMac::CtsTimeout" value="+75000.0ns"/> | ||
<default name="ns3::WifiMac::AckTimeout" value="+75000.0ns"/> | ||
<default name="ns3::WifiMac::BasicBlockAckTimeout" value="+281000.0ns"/> | ||
<default name="ns3::WifiMac::CompressedBlockAckTimeout" value="+107000.0ns"/> | ||
<default name="ns3::WifiMac::Sifs" value="+16000.0ns"/> | ||
<default name="ns3::WifiMac::EifsNoDifs" value="+60000.0ns"/> | ||
<default name="ns3::WifiMac::Slot" value="+9000.0ns"/> | ||
<default name="ns3::WifiMac::Pifs" value="+25000.0ns"/> | ||
<default name="ns3::WifiMac::Rifs" value="+2000.0ns"/> | ||
<default name="ns3::WifiMac::MaxPropagationDelay" value="+3333.0ns"/> | ||
<default name="ns3::WifiMac::Ssid" value="default"/> | ||
<global name="RngSeed" value="1"/> | ||
</ns3> |
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not advocating for any kind of change, but wanted to point out some thoughts for future cases like this:
Generally at a design level, this is where something like a state machine would be good to consider. Right now you've got two variables
is_get_closer
andis_stopped
(and possibly others here) that are really representing a single underlying state of the algorithm. The key is that these two variables are mutually exclusive, as far as I can tell, that theis_get_closer
should never be true whileis_stopped
is true, and vice-versa. So they really encode an aspect of a single actual piece of information, having them as two separate variables like this doesn't really enforce or communicate that relationship between them.A state machine implementation for something like this could be as simple as identifying the states of the algorithm and then defining an enum with a value per state:
and then tracking it as a single
self.state
variable. This way you represent that there is really only one state value at a time (rather than two truly independent variables) and represented the total possible state space within that one variable. You could then design the class in a way that uses a switch statement or different methods per state, define transition conditions for each possible transition within the state space, etc.The value of that depends on how complex the design is, probably not necessary for this particular example.