Skip to content
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

Update CARLA Ambassador to use XMLRPC Client #165

Merged
merged 12 commits into from
Nov 7, 2023

Conversation

paulbourelly999
Copy link
Contributor

@paulbourelly999 paulbourelly999 commented Oct 23, 2023

PR Details

Description

Add logic to CARLA Ambassador to use XMLRPC Client to dynamically create sensor and retrieve detections. More specifically: the CARLA Ambassador will now create a CARLA XML RPC Client on startup. Its configuration parameters (constructor arguments) will be loaded from the carla_config.json configuration file for the CARLA Ambassador. This is currently limited to carlaCDASimAdapterUrl which tells the XMLRPC client where the XMLRPC server is hosted.
Next the CARLA Ambassador now listens for Detector Registration Interactions which are triggered by the Infrastructure Ambassador in response to infrastructure registration attempts that include sensors. When receiving a Detector Registration Interaction, the CARLA Ambassador will tell the CARLA XML RPC Client to make a create_sensor request for each detector registration interaction to create the sensors in CARLA. On each timestep, which should be at 100 ms intervals, the CARLA Ambassador will now also call get_detections for every successful create_sensor attempt. This means that all the created sensor in CARLA will have their detections polled at the same interval as the CARLA Ambassador runs processTimeAdvanceGrant. The detections retrieved from the CARLA CDA Sim Adapter via the XMLRPC client will be serialized into DetectedObject(s) from json and triggered as interactions for other listening Ambassadors, mainly the infrastructure ambassador.

Related Jira Key

CDAR-209

Related Issue

#211

Motivation and Context

Add CARLA Sensor pipeline for creating sensors and getting detections for CARMA-Streets

How Has This Been Tested?

Unit testing

Types of changes

  • Defect fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that cause existing functionality to change)

Checklist:

  • 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 document.
    CARMA Contributing Guide
  • I have added tests to cover my changes.
  • All new and existing tests passed

@MishkaMN MishkaMN self-requested a review October 24, 2023 15:53
Update CARLA Ambassador to trigger interactions for detections
Updated Detector registration to include infrastructure ID
@paulbourelly999 paulbourelly999 marked this pull request as ready for review October 25, 2023 06:12
MishkaMN
MishkaMN previously approved these changes Nov 1, 2023
MishkaMN
MishkaMN previously approved these changes Nov 1, 2023
@@ -351,15 +357,29 @@ public synchronized void processTimeAdvanceGrant(long time) throws InternalFeder
nextTimeStep += carlaConfig.updateInterval * TIME.MILLI_SECOND;
isSimulationStep = false;
}
// TODO: What is this. Why are we request a time advance based on this counter and
// what is it counting. It is labeled as counting the times we attempt to connect to
// CARLA but it seems to increment every time processTimeAdvanceGrant is called
rti.requestAdvanceTime(nextTimeStep + this.executedTimes, 0, (byte) 2);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kjrush Do you have any information why were are requesting time advance like this with a continuously incremented counter? If you have any information about executedTimes and why its used in our requestAdvanceTime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did a quick skim of the rest of this PR, but so far focused on this.

I don't really see what purpose this executed times has, to be honest. It might just be entirely unnecessary. For the record, it doesn't increment infinitely. It's actually reset later on in the code inside the receiveInteraction(SimulationStepResponse) method. The interactions being received there seem to be generated whenever SUMO provides a new TraCI update, so it should be frequently, so this should never go above a small value, maybe 10 at most.

But even 10 doesn't make much sense, considering this requestAdvanceTime arg is in milliseconds, and there's no multiplicative factor applied to this executedTimes value (unlike carlaConfig.updateInterval above), so it's small enough it probably doesn't actually do anything. I imagine it was implemented like this with the goal that if we don't have any fresh data from sumo, we should wait longer to delay the CARLA updates until we do have fresh data. But I'm not sure that's needed and it seems unlikely this is actually accomplishing that.

I think you were right to be questioning about this line, but in the end I'm not sure it matters one way or the other. I'd be in favor of just removing it, but keeping this line in our mental bookmarks in case we run into issues with the ambassador. If we hit those issues we'll have this top of mind to re-investigate.

Copy link

sonarcloud bot commented Nov 2, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 2 Code Smells

77.5% 77.5% Coverage
0.0% 0.0% Duplication

warning The version of Java (11.0.21) you have used to run this analysis is deprecated and we will stop accepting it soon. Please update to at least Java 17.
Read more here

@MishkaMN MishkaMN merged commit e9629a0 into develop Nov 7, 2023
6 checks passed
@paulbourelly999 paulbourelly999 deleted the feature/carla-ambassador-xml-rpc-client branch November 8, 2023 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants