Page 1 of 1

Speed commands don't respect min/max position

Posted: Fri Sep 08, 2017 10:35 am
by cengh
I have set up the Roboclaw 2x7A with encoders to use the position commands. Everything works well and it correctly stops when it reaches the min or max position I have set. However, these limits are not respected when I use the MixedSpeedDistance command. The Roboclaw moves right past the position limits. Is this by design? Are there any commands that I can use to control the Roboclaw using speed, accel and distance but still have it be limited by the min/max positions?

Re: Speed commands don't respect min/max position

Posted: Fri Sep 08, 2017 11:19 am
by robof
I could be wrong, but I believe that is the case and only position commands follow the min/max constraints.

However, you could do this with two commands right? Read your current encoder position, and add the distance you want to travel, to allow you to use a position command?
Something like this?

Code: Select all

distance_to_travel = 55000
address = 128
accel = 0
speed = 0
decel = 0
clear_buffer = 1

current_position = roboclaw.ReadEncM1(address)

new_position = current_position + distance_to_travel

roboclaw.SpeedAccelDeccelPositionM1(address, accel, speed, decel, new_position, clear_buffer)

Re: Speed commands don't respect min/max position

Posted: Fri Sep 08, 2017 11:34 am
by cengh
Thanks for your reply, @robof. Yes, I think you are right that using those two commands we could make it work. The down side is the latency that it would introduce to first read back the position and then set the accel/velocity/position. But I will give that a try. Thanks!

Re: Speed commands don't respect min/max position

Posted: Mon Sep 11, 2017 11:25 am
by Basicmicro Support
Yes, Velocity commands do not use the min and max position settings. Those are only used by the position commands(which is why the min and max position settings are only available in the Position settings screen).

If you need position limits, I recommend you use position control instead of velocity control. It takes a little more work(sometimes very little) to tune, but it will give you absolute position control which is what it sounds like you need.

Re: Speed commands don't respect min/max position

Posted: Tue Sep 12, 2017 9:07 am
by cengh
Thank you for your replies. One more question: is the MixedSpeedAccelDeccelPosition method considered a position command or a velocity command? It seems to accept both types of parameters.

Re: Speed commands don't respect min/max position

Posted: Tue Sep 12, 2017 10:15 am
by Basicmicro Support
Yes, that is a position command. There are only three position commands. One for M1, one for M2 and one for both at once.