-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add an python example to change speeds #502
Merged
clalancette
merged 34 commits into
master
from
clalancette/addagent-return-pointer-pykeepalive
Aug 15, 2018
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
10768dc
Remove GetAgentById.
clalancette ab86154
Small include fixups.
clalancette 2bccea3
Add py::keep_alive to the constructors for the classes.
clalancette 1c1d411
Remove a now obsolete comment.
clalancette 5c5550a
Add in a simple velocity controller.
clalancette 8c4e00d
Increase the nominal (max) speed allowed for the rail cars.
clalancette 66b8e30
Connect up a ConstantVectorSource to the Velocity Controller.
clalancette 736f7a0
Rename get_current_simulation_time -> GetCurrentSimulationTime.
clalancette ee39e81
Expose get_current_simulation_time to the python API.
clalancette 2b2844f
Change return value of GetDiagram and expose to Python.
clalancette 5629b97
Add GetMutableContext, and expose to python.
clalancette b0916de
Add a SetVelocity call to the RailCar.
clalancette a514c9c
Make sure to return the agent pointer from add_rail_car.
clalancette 5150ecf
Add a new demo to show off changing the speed over time.
clalancette 290ad4d
Switch to using a class for monitoring the timeout.
clalancette 59cc0cb
Remove unnecessary py::keep_alive.
clalancette bd338c6
Fixes from review.
clalancette ecc7cbc
Rename VelocityController -> SpeedController.
clalancette 106e3af
Add in a speed system, rather than a controller.
clalancette 1d36def
Protect speed_ with a mutex.
clalancette 73ba8bf
Make sure to initialize the SpeedSystem properly.
clalancette 2f7d817
Switch to returning an AgentBase pointer from AddAgent.
clalancette 3c9671f
Fix review comments.
clalancette b3d4e25
Switch to a more generic constant_vector_settable.
clalancette be082b7
Revert "Switch to a more generic constant_vector_settable."
clalancette 0c42cb1
Make SpeedSystem a templatized class.
clalancette 8259cf9
Remove SetDefaultState.
clalancette 85bd388
Split into two systems.
clalancette 34220f9
Fix cpplint errors.
clalancette 180a3c6
Fixes for update to latest drake.
clalancette de02677
Rename ConstantVectorSettable to VectorSource.
clalancette c962c66
Add TODO comment about make VectorSource an N-vector.
clalancette fbf8ede
Move the speed changing demo into the scriptlet demo instead.
clalancette 355fe8f
More small fixes from review.
clalancette 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
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
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.
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.
@clalancette I had to test the
delphyne-crash
demo several times because I couldn't understand how it was not breaking. I would have thought that a returning a vector by-value and sticking areference_internal
return value policy to the binding would've left us with a dangling reference to a value in the stack (as intermediary containers are not internal to the simulator, only the leaf pointers are) but, alas, it doesn't. It seems I failed to see thatpybind11
code that deals with STL containers always returns a Python primitive (list, tuple, etc.) regardless of the specified return value policy.So kudos, no need for the solution in #508 for this specific issue.
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.
But wouldn't the existing code have the same problem? It is also returning a vector by value, just templated on different types. Or am I misunderstanding your point?
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.
The implementation on master was not using a
reference_internal
return value policy (check here). Yours is and to my surprise it works just fine (unless I've misunderstood a part of pybind11).