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

Support spawning during log playback #346

Merged
merged 4 commits into from
Sep 11, 2020
Merged

Conversation

nkoenig
Copy link
Contributor

@nkoenig nkoenig commented Sep 11, 2020

This automatically includes the usercommands plugin during log playback in order to support spawning on new models.

I added in a SetEntityCreateOffset function to prevent entity ID collisions. Logplayback will directly insert entities with their recorded ids, which doesn't alter the entityCount. As a result, a spawn call will attempt to create an entity with an existing ID.

See issue #347

Signed-off-by: Nate Koenig [email protected]

Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

I think an alternative implementation would be to increase entityCount within EntityComponentManagerPrivate::CreateEntityImplementation whenever the entity being created has a higher number than the current entityCount.

I think this would cover your use case without the need to hardcode an offset for log playback. It would also avoid exposing the ECM's internal counting mechanism in case we ever want to change it.

@@ -209,6 +209,10 @@ void LogPlayback::Configure(const Entity &,
// Prepend working directory if path is relative
this->dataPtr->logPath = common::absPath(this->dataPtr->logPath);

// Set the entity offset.
// \todo This number should be included in the log file.
_ecm.SetEntityOffset(90000);
Copy link
Contributor

Choose a reason for hiding this comment

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

How about ticketing an issue for keeping track of the max entity count during log record?

Also, maybe a number like std::numeric_limits<int64_t>::max() / 2 could be more generic than the current number.

Copy link
Contributor Author

@nkoenig nkoenig Sep 11, 2020

Choose a reason for hiding this comment

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

The issue is #347.

Changed offset to use half of the max value in 8a2b44c

src/EntityComponentManager.cc Show resolved Hide resolved
@nkoenig
Copy link
Contributor Author

nkoenig commented Sep 11, 2020

I think an alternative implementation would be to increase entityCount within EntityComponentManagerPrivate::CreateEntityImplementation whenever the entity being created has a higher number than the current entityCount.

I think this would cover your use case without the need to hardcode an offset for log playback. It would also avoid exposing the ECM's internal counting mechanism in case we ever want to change it.

Yeah, I tried that but it fails when the log file spawns a new entity. For example:

  1. Start log playback paused.
  2. Spawn a new element.
  3. Start playback
  4. Log file inserts a new entity. This entity could have have same id as the entity in step 2.

Nate Koenig added 2 commits September 11, 2020 12:32
Signed-off-by: Nate Koenig <[email protected]>
Signed-off-by: Nate Koenig <[email protected]>
@codecov
Copy link

codecov bot commented Sep 11, 2020

Codecov Report

Merging #346 into ign-gazebo2 will increase coverage by 24.33%.
The diff coverage is 76.44%.

Impacted file tree graph

@@               Coverage Diff                @@
##           ign-gazebo2     #346       +/-   ##
================================================
+ Coverage        53.78%   78.12%   +24.33%     
================================================
  Files              121      183       +62     
  Lines             5838    10025     +4187     
================================================
+ Hits              3140     7832     +4692     
+ Misses            2698     2193      -505     
Impacted Files Coverage Δ
include/ignition/gazebo/EntityComponentManager.hh 100.00% <ø> (ø)
include/ignition/gazebo/Server.hh 100.00% <ø> (ø)
include/ignition/gazebo/ServerConfig.hh 100.00% <ø> (ø)
...nclude/ignition/gazebo/components/Serialization.hh 61.29% <0.00%> (+61.29%) ⬆️
.../plugins/component_inspector/ComponentInspector.cc 9.41% <0.00%> (ø)
src/systems/breadcrumbs/Breadcrumbs.hh 100.00% <ø> (ø)
src/systems/diff_drive/DiffDrive.hh 100.00% <ø> (ø)
src/systems/joint_controller/JointController.hh 100.00% <ø> (ø)
...stems/joint_state_publisher/JointStatePublisher.hh 100.00% <ø> (ø)
src/systems/physics/Physics.cc 74.12% <ø> (+58.14%) ⬆️
... and 129 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5c151bf...d9001c7. Read the comment docs.

Copy link
Contributor

@chapulina chapulina left a comment

Choose a reason for hiding this comment

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

I tried that but it fails when the log file spawns a new entity.

Oh got it, makes sense, I didn't think about the order of operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📜 blueprint Ignition Blueprint
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants