Repository navigation
Keep motor indices in the order passed to init_arm_motors() - #176
Open
pradeepsuryad wants to merge 2 commits into
Open
pradeepsuryad wants to merge 2 commits into
pradeepsuryad wants to merge 2 commits into
Conversation
DMDeviceCollection indexed motors by their position in get_dm_devices(),
which walked CANDeviceCollection's std::map and so came out in recv-id
order. With the ids passed out of ascending order, per-motor settings went
to the wrong motors: init_arm_motors({DM4310, DM4310}, {0x02, 0x01},
{0x12, 0x11}, {MIT, POS_VEL}) gave MIT to 0x01.
Keep an insertion-ordered vector next to the map, which stays for recv-id
lookup, and have get_dm_devices() walk it. Re-adding a recv id replaces
that device in place.
Fixes enactic#162.
|
Congratulations! One of the builds has completed. 🍾 You can install the built RPMs by following these steps:
Please note that the RPMs should be used only in a testing environment. |
This was referenced Nov 5, 2026
This branch has not been deployed
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Fixes #162.
DMDeviceCollection::get_dm_devices()walkedCANDeviceCollection'sstd::map, so motor indexiwas the i-th motor in recv-id order rather than the i-th one passed toinit_arm_motors(). This follows the proposal in #162:CANDeviceCollectionkeeps an insertion-ordered vector next to the map, exposed asget_devices_in_order().add_device()andremove_device()keep the two in step, and re-adding a recv id replaces that device in place. The map, andget_devices(), stay for recv-id lookup.get_dm_devices()walks the ordered list, soget_motors(),get_motor(i),get_link_stats(i), the*_one(i, ...)methods and the*_all(vector)methods all follow the order the motors were passed in.With the ids passed in ascending order nothing changes.
It also stops
diagnose --id 8,1from attaching rows to the wrong ids:run_diagnose()labels its rows from the ids in command-line order and reads their stats withget_link_stats(i). A repeated id such as--id 1,1still leaves an empty row; I've left that for #161.Test
No motors needed. On
vcan0(GitHub Actions, Ubuntu 22.04 and 24.04), a small program runs the example from #162 (ids0x02, 0x01withMIT, POS_VEL) and an ascending case. For each, it checks thatget_motors()is in the order the ids were passed, and that each motor accepts a command in the mode it was given (get_link_stats(i): sent, not rejected).On
main, the #162 case fails all three checks; with this branch both cases pass: https://github.com/pradeepsuryad/openarm_can/actions/runs/42076008764The check program is on a separate branch of my fork. I can add it to the repository as a test if you'd like one.