-
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
Fix-unrealistic-CANMotorMediator #112
Conversation
…l use them to test CAN motor controllers as well.
Currently, CAN motor messages don't seem to be sent over halsim ws.
@CoolSpy3, do you have any idea why SimDevice messages don't appear to be being sent over halsim ws? At the moment, this branch is setup such that:
When the MotorControllerTest systemTest is run, a breakpoint at the beginning of CANMotorSim.processMessage() never gets hit. Any idea why? |
To be clear, the CI tests are just failing because the controller is currently external. |
Alright, after some testing, I've figured out part of it. You have to add |
I think I found the other bug. Testing now. |
Try this. For some reason, simulating the extern controller locally is taking an unreasonably long time to process callbacks (i.e. many seconds for my breakpoints to be hit after the robot code sends a message). Edit: It looks like events are being queued faster than the controller can process them. |
I'm still not seeing the breakpoint get hit and the second flywheel doesn't turn. Is it turning for you? I even let the test run for 30 secs instead of just 3 secs. How long is the delay before you see it hit the breakpoint? |
Fwiw, I started down this path because I was experiencing a similar problem when trying move the time sync from NT back to hal sim to fix #101. What I saw was seeing was that if I created a |
It appears to be related to my testing methodology :/ In order to not have to run the full suite, I've been testing by running With this, the breakpoint in If I just run the suite, |
What I'm Seeing: When running the test, |
Thanks! Although I haven't yet had a chance to try running the robot code outside the tests (my machine is underground an os upgrade at the moment), the behavior you are seeing when running the tests is consistent with what I was seeing. At least I know I'm not crazy! 😄 |
It appears to be caused by WebotsSimulator:743 (commenting that line out solves the problem). I'm not sure how though. The callbacks aren't initialized until later, and that method appears to be synchronous. |
I think I figured it out. When a ws connection is created, I have to work on some other stuff now, but I can verify and open a WPILib issue later. |
Nice work! Thanks! |
- Use the WPIWebSockets associated with DeepBlueRobotics/WPIWebSockets#52. - Only call Simulation.runPeriodicMethods() once per simulation step. - Make CANMotorMediator.java physically realistic. - Remove calls to SimDeviceSim.resetData() because doing so prevents HALSimWS from working with any future SimDevices. - Make MotorController.wbt use the the DeepBlueSim controller again instead of an extern controller, since we don't need to run in the debugger right now. - Return to using SimHooks.stepTiming() for speed.
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.
Just a couple minor suggestions/cleanup.
...in/controller/src/main/java/org/carlmontrobotics/deepbluesim/mediators/CANMotorMediator.java
Outdated
Show resolved
Hide resolved
...in/controller/src/main/java/org/carlmontrobotics/deepbluesim/mediators/CANMotorMediator.java
Outdated
Show resolved
Hide resolved
...in/controller/src/main/java/org/carlmontrobotics/deepbluesim/mediators/CANMotorMediator.java
Show resolved
Hide resolved
plugin/libdeepbluesim/src/main/java/org/carlmontrobotics/libdeepbluesim/WebotsSimulator.java
Show resolved
Hide resolved
plugin/controller/src/webotsFolder/dist/protos/deepbluesim/DBSBuiltinEncoderBase.proto
Show resolved
Hide resolved
…im/mediators/CANMotorMediator.java Co-authored-by: CoolSpy3 <55305038+CoolSpy3@users.noreply.github.com>
…im/mediators/CANMotorMediator.java Co-authored-by: CoolSpy3 <55305038+CoolSpy3@users.noreply.github.com>
… that point SimDevices are no longer needed.
I think I've addressed everything. |
…otorRotationInAutonomous().
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.
Looks good!
Currently, CAN motor messages don't seem to be sent over halsim ws.