-
Notifications
You must be signed in to change notification settings - Fork 276
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 a service to trigger functionality #1611
Conversation
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Added 3 more tests for the triggered_publisher.cc.
All tests have been passed |
Signed-off-by: Liam Han <[email protected]>
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.
Did a static pass. Mostly style.
Note to self: Haven't looked at test/integration/triggered_publisher.cc
yet.
Bionic CI is failing on some style items
|
@mabelzhang Thank you so much for the thorough review! And sorry about all the silly syntax/grammar mistakes haha But please keep providing me all these feedback so that I can learn (: Question
I'll push the updated syntax-fix later tonight and work on the fix for the service tomorrow. |
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Codecov Report
@@ Coverage Diff @@
## ign-gazebo6 #1611 +/- ##
===============================================
+ Coverage 64.69% 64.73% +0.03%
===============================================
Files 321 321
Lines 26062 26122 +60
===============================================
+ Hits 16862 16911 +49
- Misses 9200 9211 +11
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
…correct request type and false result Signed-off-by: Liam Han <[email protected]>
… and test Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
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.
Thanks for iterating! Last style comments.
Some tests on CI are failing but this PR isn't changing any files other than this one plugin.
One test seems flaky locally for me:
$ ./build/ignition-gazebo6/bin/INTEGRATION_triggered_publisher
...
/home/developer/ign_fortress/src/ign-gazebo/test/integration/triggered_publisher.cc:728: Failure
Expected equality of these values:
pubCount
Which is: 10
recvCount
Which is: 9
[ FAILED ] TriggeredPublisherTest.InputMessagesTriggerServices (6074 ms)
...
[ FAILED ] 1 test, listed below:
[ FAILED ] TriggeredPublisherTest.InputMessagesTriggerServices
I ran the tests locally twice in a row, and it failed once, then passed. I ran it more times, and then it always passed. Maybe it was something to do with timing the first time I ran it, but I still took a closer look at that test and made some comments.
The main thing is, we don't want to be adding flaky tests. If they are already flaky at the time of creation, then we should fix that. Can you see if it's ever flaky for you?
return true; | ||
} | ||
return false; |
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.
Are these return values being checked anywhere? Are they needed?
If they're returning a value for a reason, they should be checked in the test. If they aren't there for any specific reason, then they aren't needed.
hmm I'm not getting any error locally on my side. I ran at least 30 times with no error. I also tried testing it with 100 and 500 publications instead of just 10 (which is the value I used for all the tests). And I didn't get any errors. Reading the error msg, the pubCount is 10 but the recvCount is 9. Which means that one publication wasn't handled by the callback. The question is whether it was the first publication that missed the callback or from one of the following publications. If the service server was NOT setup on time, it should've thrown a timeout error. Did you see any error msg like this when you ran it locally? It's weird that it only occurred on one of the test when all the subsequent test have similar structure. So I would've expected similar behavior on other tests... But unless we reproduce the same error, I think it might be hard to know what could've caused it. |
…lient service Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Liam Han <[email protected]>
update: It was caused by callback method looping faster than the DoWork method. Hence, the triggerSrv variable could've been set twice in the callback while only invoked once in the DoWork method. Both the callback and DoWork methods are running on separate thread. For example, the callback method might have looped twice and set the triggerSrv twice. But if the DoWork was still in progress, it'll only call the service one. And triggerSrv is just a boolean value. So it doesn't have a record of iteration. To fix this, I reverted back using the serviceCount, similar to the publishCount. This will prevent any skipping. In an extreme case, let's say that callback looped 4 times while DoWork looped once. At next iteration, the DoWork will call the service whatever the serviceCount value is and not skip anything. In most case, serviceCount should be 1. But in cases where callback is faster. the serviceCount >1. This approach will be yield least flaky test |
… threads running at different rate Signed-off-by: Liam Han <[email protected]>
Signed-off-by: Mabel Zhang <[email protected]>
Good find! Thanks for troubleshooting the flaky test! It seems reasonable what you did. It was hard to reproduce for me even the first time, so I can't really test it reliably and say it's better. It passes locally for me. Hopefully it doesn't become flaky on CI. I think I wasn't clear about which indentations I was talking about in the last review, so I pushed a few nit style changes in fced8fb. Faster than going back and forth. Thanks for removing the ID as well. I'm wrapping up for the week. Just waiting for CI. Should be good to go next week. |
ABI checker is failing in the checks below Removed Symbols 7
Problems with Constants, Low Severity 1
Can you merge from the target branch and see if that fixes it? |
ABI check is the last thing before approval and merge. The other test failures look irrelevant since this PR only touches triggered publisher. |
Thanks - ABI check is passing. Sorry I hadn't seen this earlier, but these gcc warnings will need to be fixed: I think you can either comment out |
Signed-off-by: Liam Han <[email protected]>
I removed the https://build.osrfoundation.org/job/ignition_gazebo-ci-pr_any-ubuntu_auto-amd64/9628/ |
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.
Thanks for iterating!
I think the warnings should show up at compile time? I'm not sure. I haven't run the latest version locally.
CI looks good. Make sure to use Squash Merge.
Brilliant! Thanks for all the thorough review Mabel! |
found a silly typo that was pushed back in PR (#1611)
found a silly typo that was pushed back in PR (#1611)
* initial commit to allow plugin to call a service Signed-off-by: Liam Han <[email protected]> * adding tutorial and modifying the world sdf Signed-off-by: Liam Han <[email protected]> * added test for single input and single service output Signed-off-by: Liam Han <[email protected]> * added test for single input and multiple service output Signed-off-by: Liam Han <[email protected]> * added test for invalid matching service name => timeout Signed-off-by: Liam Han <[email protected]> * modified variables the camelCase Signed-off-by: Liam Han <[email protected]> * fixed typo, indentation, grammar, lines that exceeded 80 char Signed-off-by: Liam Han <[email protected]> * fixing ubuntu bionic ci issue Signed-off-by: Liam Han <[email protected]> * silly syntax mistake on expect_eq Signed-off-by: Liam Han <[email protected]> * added three more test cases that addesses incorrect response type, incorrect request type and false result Signed-off-by: Liam Han <[email protected]> * WIP: major restructuring and currently working. Requires more cleanup and test Signed-off-by: Liam Han <[email protected]> * WIP: fixed preprocessor define bug Signed-off-by: Liam Han <[email protected]> * WIP: working but extremely convoluted Signed-off-by: Liam Han <[email protected]> * WIP major modification but a lot of errors and tests failed Signed-off-by: Liam Han <[email protected]> * stable version: had to revert back to previous work. all tests passed Signed-off-by: Liam Han <[email protected]> * modified to use blocking Request method as well as reduce a service worker thread to just one thread with the publisher. all tests passed Signed-off-by: Liam Han <[email protected]> * stable version: had to revert back to previous work. all tests passed Signed-off-by: Liam Han <[email protected]> * successfully reverted and tested Signed-off-by: Liam Han <[email protected]> * fixing PR suggestions Signed-off-by: Liam Han <[email protected]> * changed string with 'serv' to 'srv' and included <mutex> to the header Signed-off-by: Liam Han <[email protected]> * fixed indentation and removed rep.set_data since it's unused on the client service Signed-off-by: Liam Han <[email protected]> * getting rid of the id Signed-off-by: Liam Han <[email protected]> * fixed race condition resulting seldom test failure Signed-off-by: Liam Han <[email protected]> * changed from triggerSrv to serviceCount. This compensates for the two threads running at different rate Signed-off-by: Liam Han <[email protected]> * braces indentation Signed-off-by: Mabel Zhang <[email protected]> * addressing gnu c compiler (gcc) warnings Signed-off-by: Liam Han <[email protected]> Signed-off-by: Liam Han <[email protected]> Signed-off-by: Mabel Zhang <[email protected]> Co-authored-by: Mabel Zhang <[email protected]> Signed-off-by: Silvio <[email protected]>
* Add topic parameter to thrust plugin (#1681) * Add topic parameter. Signed-off-by: Carlos Agüero <[email protected]> * 🎈 6.12.0: bumped minor and updated changelog (#1682) * bumped minor and updated changelog Signed-off-by: Dharini Dutia <[email protected]> * fixed changelog as per feedback and updated migration guide Signed-off-by: Dharini Dutia <[email protected]> Signed-off-by: Dharini Dutia <[email protected]> * Fix reference link in ackermann steering (#1683) Signed-off-by: Kenji Brameld <[email protected]> * Fix installation instructions on Ubuntu 22.04 (#1686) Signed-off-by: Silvio Traversaro <[email protected]> * Add a service to trigger functionality (#1611) * initial commit to allow plugin to call a service Signed-off-by: Liam Han <[email protected]> * adding tutorial and modifying the world sdf Signed-off-by: Liam Han <[email protected]> * added test for single input and single service output Signed-off-by: Liam Han <[email protected]> * added test for single input and multiple service output Signed-off-by: Liam Han <[email protected]> * added test for invalid matching service name => timeout Signed-off-by: Liam Han <[email protected]> * modified variables the camelCase Signed-off-by: Liam Han <[email protected]> * fixed typo, indentation, grammar, lines that exceeded 80 char Signed-off-by: Liam Han <[email protected]> * fixing ubuntu bionic ci issue Signed-off-by: Liam Han <[email protected]> * silly syntax mistake on expect_eq Signed-off-by: Liam Han <[email protected]> * added three more test cases that addesses incorrect response type, incorrect request type and false result Signed-off-by: Liam Han <[email protected]> * WIP: major restructuring and currently working. Requires more cleanup and test Signed-off-by: Liam Han <[email protected]> * WIP: fixed preprocessor define bug Signed-off-by: Liam Han <[email protected]> * WIP: working but extremely convoluted Signed-off-by: Liam Han <[email protected]> * WIP major modification but a lot of errors and tests failed Signed-off-by: Liam Han <[email protected]> * stable version: had to revert back to previous work. all tests passed Signed-off-by: Liam Han <[email protected]> * modified to use blocking Request method as well as reduce a service worker thread to just one thread with the publisher. all tests passed Signed-off-by: Liam Han <[email protected]> * stable version: had to revert back to previous work. all tests passed Signed-off-by: Liam Han <[email protected]> * successfully reverted and tested Signed-off-by: Liam Han <[email protected]> * fixing PR suggestions Signed-off-by: Liam Han <[email protected]> * changed string with 'serv' to 'srv' and included <mutex> to the header Signed-off-by: Liam Han <[email protected]> * fixed indentation and removed rep.set_data since it's unused on the client service Signed-off-by: Liam Han <[email protected]> * getting rid of the id Signed-off-by: Liam Han <[email protected]> * fixed race condition resulting seldom test failure Signed-off-by: Liam Han <[email protected]> * changed from triggerSrv to serviceCount. This compensates for the two threads running at different rate Signed-off-by: Liam Han <[email protected]> * braces indentation Signed-off-by: Mabel Zhang <[email protected]> * addressing gnu c compiler (gcc) warnings Signed-off-by: Liam Han <[email protected]> Signed-off-by: Liam Han <[email protected]> Signed-off-by: Mabel Zhang <[email protected]> Co-authored-by: Mabel Zhang <[email protected]> * Fix loading render engine plugins in GUI (#1694) Signed-off-by: Ian Chen <[email protected]> * Enable inherited model topic name. (#1689) Allows for inheriting model name for robotNamespace when SDF element is not set and provides a debug message showing the topics it subscribes to. Signed-off-by: Benjamin Perseghetti <[email protected]> Co-authored-by: Nate Koenig <[email protected]> * Add ResourceSpawner example file (#1701) Add an example file for the ResourceSpawner plugin. I'm using this to link from https://github.com/gazebosim/docs/blob/master/garden/Model_insertion_fuel.md. To improve gazebosim/garden-tutorial-party#1991. Signed-off-by: Jose Luis Rivero <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> * Update triggered_publisher.sdf (#1737) found a silly typo that was pushed back in PR (#1611) * Adds sky cubemap URI to the sky.proto's header (#1739) * Adds sky cubemap URI to the sky.proto's header Signed-off-by: Nate Koenig <[email protected]> * require sdf 12.6 Signed-off-by: Nate Koenig <[email protected]> Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> * Return absolute path when finding a resource (#1741) * Adds sky cubemap URI to the sky.proto's header Signed-off-by: Nate Koenig <[email protected]> * Return absolute path when finding a resource Signed-off-by: Nate Koenig <[email protected]> Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> * Restore Add System GUI plugin (#1685) * cherry pick aef3020 Signed-off-by: Ian Chen <[email protected]> * Adding thrust coefficient calculation (#1652) * adding thrust coefficient calculation Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.cc Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * Update src/systems/thruster/Thruster.hh Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> * thrust coefficient test and behavior updates Signed-off-by: Marco A. Gutierrez <[email protected]> * making float comparision more robust Signed-off-by: Marco A. Gutierrez <[email protected]> * fix float comparision and lint Signed-off-by: Marco A. Gutierrez <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> * Enable/Disable individual hydrodynamic components. (#1692) This commit enables and disables individual components of the hydrodynamics. This is often useful for debugging odd behaviours of a hydrodynamic model. * Fortress: Removed warnings (#1754) * Fortress: Removed warnings * Removed unused speedlimit file (#1761) Signed-off-by: ahcorde <[email protected]> * Enable use of ign gazebo -s on Windows (take two) (#1764) * Enable use of ign gazebo -s on Windows Signed-off-by: Silvio <[email protected]> * Update src/CMakeLists.txt Co-authored-by: Alejandro Hernández Cordero <[email protected]> Signed-off-by: Silvio <[email protected]> * Fix cmdmodel6.rb and cmdgazebo6.rb contining the same code Signed-off-by: Silvio <[email protected]> Signed-off-by: Silvio <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> * Script and tutorial for generating procedural datasets with Blender (#1412) Signed-off-by: Andrej Orsula <[email protected]> * Fix scene_broadcaster_system test (#1766) Signed-off-by: Nate Koenig <[email protected]> Signed-off-by: Nate Koenig <[email protected]> Co-authored-by: Nate Koenig <[email protected]> * Lint Signed-off-by: Michael Carroll <[email protected]> * Clean build and update test Signed-off-by: Nate Koenig <[email protected]> Signed-off-by: Carlos Agüero <[email protected]> Signed-off-by: Dharini Dutia <[email protected]> Signed-off-by: Kenji Brameld <[email protected]> Signed-off-by: Silvio Traversaro <[email protected]> Signed-off-by: Liam Han <[email protected]> Signed-off-by: Mabel Zhang <[email protected]> Signed-off-by: Ian Chen <[email protected]> Signed-off-by: Benjamin Perseghetti <[email protected]> Signed-off-by: Jose Luis Rivero <[email protected]> Signed-off-by: Nate Koenig <[email protected]> Signed-off-by: Marco A. Gutierrez <[email protected]> Signed-off-by: ahcorde <[email protected]> Signed-off-by: Silvio <[email protected]> Signed-off-by: Andrej Orsula <[email protected]> Signed-off-by: Michael Carroll <[email protected]> Co-authored-by: Carlos Agüero <[email protected]> Co-authored-by: Dharini Dutia <[email protected]> Co-authored-by: Kenji Brameld <[email protected]> Co-authored-by: Silvio Traversaro <[email protected]> Co-authored-by: Liam Han <[email protected]> Co-authored-by: Mabel Zhang <[email protected]> Co-authored-by: Ian Chen <[email protected]> Co-authored-by: Benjamin Perseghetti <[email protected]> Co-authored-by: Jose Luis Rivero <[email protected]> Co-authored-by: Alejandro Hernández Cordero <[email protected]> Co-authored-by: Nate Koenig <[email protected]> Co-authored-by: Marco A. Gutierrez <[email protected]> Co-authored-by: Arjo Chakravarty <[email protected]> Co-authored-by: Andrej Orsula <[email protected]> Co-authored-by: Michael Carroll <[email protected]>
🎉 New feature
Summary
Extended the trigger publisher functionality to allow calling a service. For this example, I've reset the
pose
of the robot as well as set thecmd_vel
value to0
, hence stopping the robot. This will allow others to use triggered publisher for calling arbitrary number of services as an "output" from the plugin.service.demo.mp4
Test it
I have modified the
tutorial/triggered_publisher.md
tutorial to add this functionality. The world file,examples/words/triggered_publisher.sdf
also reflects this.liam/add-serv-to-trig-pub
branch and rebuildign gazebo triggered_publisher.sdf
ign topic -t "/start" -m ignition.msgs.Empty -p " "
to run the original triggered publisher example.ign topic -t "/reset_robot" -m ignition.msgs.Empty -p " "
to reset the robot (calling the reset pose service)./build/ignition-gazebo6/bin
and run./INTEGRATION_triggered_publisher
Checklist
codecheck
passed (See contributing)Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining
Signed-off-by
messages.