Im using a bdcm with halls feedback in position mode. My application needs to issue incremental positions (i.e. every position command must rotate the motor cw or ccw a specific amount from the last movement). Since this is a ground vehicle, it could move miles in any direction which would overflow the position since its stored as a float.
So I created a ‘reset position’ command (i designated it ‘t’) in the acsii_protocol.cpp. In text function I created for the ‘t’ command, I call a function in axis.cpp that first sets encoder_.pos_estimate_ = 0, then calls controller_.reset(). The result is just moving the motor back to position 0, not what I need. I want it to set its current position to 0 again w/o moving the motor to 0.
You can’t directly write to pos_estimate, it is being controlled by the encoder module. Use the function
If this works well, can you please make a PR? I think this is a feature others would also have good use of.
It works, but its not a very clean solution. I first must issue a position command, then figure out when the motor has stopped moving (I do this by reading the pll_velocity), then issue my ‘t’ command. The best solution would be an ‘incremental position mode’. Im going to try to implement it…some guidance would be appreciated (like which update loop should I be sticking this into?).
We have an incremental mode coming soon, but in that particular implementation it won’t handle rotating “forever”.
I think a better solution is to extend your
t command to include an offset parameter to shift the reference by. You can call like
t 0 -100000 to shift back the reference by that much, and also shift the reference on the host at the same time. Then you don’t have to stop: because you are shifting the same amount on both sides you never lost any counts.
The implementation is probably as easy as:
set_linear_count(shadow_count_ + delta);
delta is the new parameter of your
I see how that could work better, but im worried about the position eventually overflowing since the motors could be moving for hours. The guidance system sends a new position every 10 seconds. If the new position requires the ugv to turn, then the controlling software waits for the motors to stop (from the last position move), then skid steers to a new heading and the process starts again. Otherwise, if it’s moving straight, a new position must be sent w/o stopping. Since the position and reset commands are separate, everything is working ok.
Couldn’t you use
odrv0.axis0.controller.move_to_pos(odrv0.axis0.controller.move_to_pos + INCREMENT)
FW 4.8 supports incremental trajectory planned moves with the
<float> is the incremental distance, in counts, and the
<bool> is “from goal point”. In other words, if you command
move_to_pos(100000) and then
move_incremental(-1) before the previous move is done, your final destination position will change to 99999. If
<bool> is false, it’s the axis’s current position + the increment. So the axis would decelerate to a stop, then move backwards if you commanded -1. By default,
<bool> is = True and it’s an optional value.
I tried this function
but it says object has no attribute set_linear_count
I also need to be able to zero the position without moving to 0, but i use absolute moves not relative
set_linear_count was added to python interface fairly recently (some time in March?), so you may need more recent fw.