Comments (1)
I was able to repro the issue using the code above. It also repros with mtp
, since mrp
is just a wrapper around mtp
. I think the problem is a race condition in the "motor done" logic - after the "done" flag gets cleared, it sometimes gets immediately set again, resulting in the motor not moving. More details below.
If I understand correctly, the "motor done" flag gets cleared when the motor mode register changes (see wallaby_dma.c#L226-L234):
// handle motors modes clearing done bits
// TODO: cleanup
if (address == REG_RW_MOT_MODES)
{
if (value & 0b00000011) aTxBuffer[REG_RW_MOT_DONE] &= ~1;
if (value & 0b00001100) aTxBuffer[REG_RW_MOT_DONE] &= ~2;
if (value & 0b00110000) aTxBuffer[REG_RW_MOT_DONE] &= ~4;
if (value & 0b11000000) aTxBuffer[REG_RW_MOT_DONE] &= ~8;
}
The current mtp
logic is:
Private::set_motor_mode(motor, Private::Motor::SpeedPosition); // (A)
Private::set_motor_goal_position(motor, goal_pos); // (B)
Private::set_motor_goal_velocity(motor, velocity); // (C)
Say you just called:
mtp(0, 1000, 1000);
bmd(0);
After this finishes, the goal position is 1000, the current position is around 1000, and the "done" flag is true.
Now you call mtp
again. Line (A) sets the motor mode, which clears the "done" flag. Before line (B) runs, the STM32 code may run and see that the goal position (the old one) has been reached, so it sets the "done" flag back to true. Now line (B) runs and sets the new goal position, but it's too late. The "done" flag has been set, so the motor won't move towards the new goal position.
I think the easiest solution is reordering the register writes to B, C, A. There can still be different race conditions, but thinking through the possibilities, they shouldn't result in bad behavior.
More complex but possibly better solutions could be:
- Combine the register writes so they're written together, if possible
- Move the responsibility of clearing the "done" flag to libwallaby, so
mtp
can ensure the "done" flag isn't cleared until it's time
from libwallaby.
Related Issues (20)
- Fix all compilation warnings HOT 7
- Fix/add Emscripten for JS support HOT 1
- Add a range of TCP functionality for libwallaby HOT 1
- "doc" folder is not gitignored
- Motor velocities are not capped to 1500
- Add ROS functionality HOT 1
- Update Doxygen docs (add comments)
- Get Tello working with Libwallaby HOT 2
- Get the Create3 ROS2 library working HOT 5
- Graphics does not work on Wombat HOT 2
- nullptr/cmake issue HOT 1
- ~Wallaby() destructor/constructor & removing console output HOT 2
- Fake Issue
- Standardize formatting HOT 2
- Add graphical wait_for_light back in HOT 1
- Segmentation Fault when calling certain functions HOT 6
- Resolve Tello changes with refactor
- Camera not opening - Refactor
- Create distance & angle counters overwritten
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libwallaby.