-
Notifications
You must be signed in to change notification settings - Fork 19
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
Motor.run_to_position does not reach position #179
Comments
Thanks for the report, I can replicate this too. I'll pass this on to the firmware dev, to see if this can be improved in either firmware/software. |
I just created a little script that compares the difference between the angle you're targeting vs the angle that is obtained after calling run_to_position. With the default motor bias I got an average of around 2.8 degrees out from the desired value. By increasing the motor bias to 0.4, the average was around 1.4 degrees out from the desired value. (Note that the motor in my case didn't have any load attached)
|
I have tried your suggestion with three motors, it works when there is no load on the motor. But when you put a mechanical load on the motor the results are similar to before.
Angle -90 Motor delta A:1 B:2 C:2 There is some improvement compared with no bias Angle -90 Motor delta A:2 B:2 C:139 |
Thanks for the response, I'll try testing with a load soon, I'm wondering |
@chrisruk I'm facing the same issue. With load it moves only from -29 to 51 while instructing it to move from -180 to 180. However, it does the complete round when I use the command: motor2.run_for_seconds(1, speed=80) Also, I believe in my case (robotic arm) there might be a power issue. The base motor isn't getting enough power to operate at it's full capacity |
@dhruvsheth-ai Thanks for reporting also, just wondering have you tried also passing a speed parameter to the run_to_position function (default is 20, so it might be worth trying say 30, 40..)? |
Hello @chrisruk thanks for reverting back this quick! demo-lego1.mp4This is the output from the code (I added some extra print statements): Expected -180
Actual 109
71
Expected 180
Actual 143
37
Expected 90
Actual 92
2
Expected -90
Actual 165
105
Expected 45
Actual 47
2
Expected -45
Actual -41
4
Expected 0
Actual -5
5
Expected -180
Actual -162
18
Expected 180
Actual -170
10
Expected 90
Actual 105
14
Expected -90
Actual -92
3
Expected 45
Actual 36
9
Expected -45
Actual -43
2
Expected 0
Actual -10
10
avg 20.857142857142858 Additionally, the next one is a demo video of a code asking it to run 4 loops from -180 to 180 at 70 speed for i in range(0,4):
motor2.run_to_position(180, speed=70, direction='anticlockwise')
motor2.run_to_position(-180, speed=70, direction='clockwise') And this is the attached video which shows that it manages to run just a bit more than 45 degrees rather than 360. demo-lego2.mp4Thanks for the help! |
Thanks for the videos, it looks a very cool project! I'll see if the firmware dev might have any suggestions |
@chrisruk Thanks for your help! |
I finally sorted this issue. The catch is that -180 to 180 i.e 360 degrees for buildhat is actually representative of just 45 degrees in actual rotation. A better way to sort this is using the command, x = 1.5
motor.run_for_rotations(x, speed=30, blocking=True) Here x can be any integer. 1 represents 45 degrees turned in actual conversion and 2 represents 90 degrees. before doing this, you can use the standard command to assign a particular location in the 45 degree interval motor.run_to_position(20, speed=30, direction='clockwise') After this running I thought of posting this for anyone else stuck on the same issue. |
Cool, glad you sorted it. In case you haven't seen, there's also a run_for_degrees method, which may be useful too. |
Thanks @chrisruk it works well too! |
Is there a firmware update in the pipeline for this issue ? |
There is a new firmware I'm testing that introduces a new 'slower PWM' mode. I'm just wondering what kind of load you have attached to the motor that means run_to_position currently doesn't reach the position? I can see if I can replicate a similar load and drive with the new firmware. |
Wow! Very cool! Thanks for the images. I'll experiment with some different loads with the new firmware. |
@Gadgeteering If you'd like to try the new firmware there's a pull request I've created with it - You can install doing -
For me motors now seem to work better at lower speeds, I'm wondering if this may help with your use case. The bias function is no longer available. So I used something like -
You might want to different speeds too. |
I have tried the new firmware with a load on the motor and get an average difference of 'avg 5.033333333333333', which is not good enough for my project I have resolved the issue by writing a feedback loop into the software to get a precision position of the motors import time m = Motor('A') sum_of_angle_differences = 0 |
Thanks for the response, I've just been testing altering one of the PID parameters (dead zone) to see if that helped improve accuracy for me, with a small load, along with trying rpm mode. I altered the last value on this line - https://github.com/RaspberryPiFoundation/python-build-hat/blob/main/buildhat/motors.py#L216 from My test script that I ran with the dead zone set to
Results:0.001 pid deadzone
0.01 pid deadzone
From looking at my results, it's hard to see how much of a difference altering the PID dead zone makes, however
(It's hard for me to tell though, if the RPM mode appears to work better just because the speeds might be lower than non-RPM mode, but might be worth a try) |
Motor.run_to_position does not reach position requested
Motor C requested position -66 current position -76
Motor C requested position -66 current position -76
Motor C requested position -66 current position -76
Motor C requested position -66 current position -76
Motor C requested position -66 current position -76
I have tried to correct this behaviour but when I have used run_for_degrees(10) the motor does not move
The text was updated successfully, but these errors were encountered: