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

Issue-549: Moved Kafka time producer from CDASimAdapter to CARMA-Stre… #550

Merged
merged 8 commits into from
Jul 20, 2023

Conversation

paulbourelly999
Copy link
Contributor

@paulbourelly999 paulbourelly999 commented Jul 14, 2023

…ets plugin

  • Update CARMA-Streets Plugin to be simulation time aware

PR Details

Description

Move Kafka time producer for CARMA-Streets time synchronization to CARMA-Streets plugin. This removes unnecessary dependency on kafka for CDASimAdapter and also makes CARMA-Streets Plugin contain entire interface to CARMA-Streets including simulation. CARMA-Streets Plugin now extends our simulation time aware PluginClient which can be further extended to listen for simulated messages.

Related Issue

#549
VH-1237

Motivation and Context

How Has This Been Tested?

Locally integration testing with python time step script to send udp time step messages.

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

…ets plugin

+ Update CARMA-Streets Plugin to be simulation time aware
@paulbourelly999 paulbourelly999 marked this pull request as ready for review July 17, 2023 20:07
clock = std::make_shared<CarmaClock>(simulationMode);
if (simulationMode) {
clock = std::make_shared<CarmaClock>(_simulation_mode);
if (_simulation_mode) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we need the if statement to only apply filter when it is in simulation mode? Is it possible for CDAAdapterPlugin to broadcast TimeSyncMessage when it is not in simulation mode?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it is not possible and also not valid. TimeSync messages are only valid when we are running in simulation. Otherwise we use machine time.

Copy link
Collaborator

Choose a reason for hiding this comment

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

AddMessageFilter<tmx::messages::TimeSyncMessage>(this, &PluginClientClockAware::HandleTimeSyncMessage);

The AddMessageFilter is event based and should only be triggered when there is Timsync message sent to the TMX bus in simulation mode.
so the _simulation_mode should always be true. Can we remove this if check statement? The same to the HandleTimeSyncMessage() function. There is no need to check if _simulation_mode true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is incorrect. Simulation mode will be false in real world deployments. Here the PluginClockAwareClient will not subscribe to TimeSync messages so this is valid in my opinion

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To clarify, the CDASimAdapter will only be active in simulation mode, which means we will only broadcast TimeSync messages in Simulation Mode. The PluginClockAwareClient is a PluginClient that is able to configurably use Simulation time or real time. It will only subscribe to TimeSync messages when in simulation mode. So on the broadcast side the plugin will not be active to produce time sync messages if not in simulation. On the filter side, even if something else did produce a time sync message, we will not add a filter for it if not in simulation mode.

virtual ~kafka_producer_worker();
// Rule of 5 because destructor is define (https://www.codementor.io/@sandesh87/the-rule-of-five-in-c-1pdgpzb04f)
// delete copy constructor
kafka_producer_worker(kafka_producer_worker& other) = delete;
Copy link
Collaborator

Choose a reason for hiding this comment

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

What is the purpose of deleting the copy and move constructor?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rule of 5 is a rule in C++ that if you define one of these you need to explicitly define all to avoid issues with compiler generated versions. This is to address a Code Smell. (https://www.codementor.io/@sandesh87/the-rule-of-five-in-c-1pdgpzb04f)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I left a comment as well

@dan-du-car dan-du-car merged commit 77127e2 into develop Jul 20, 2023
7 of 8 checks passed
@dan-du-car dan-du-car deleted the 549-move-time-kafka-producer branch July 20, 2023 20:07
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.

2 participants