DriveBase.curve in Reverse #1240
Replies: 4 comments 7 replies
-
|
I’m traveling so my answer is a bit short, but you can use a negative angle to ‘reverse’. Try drawing a picture of a robot traversing a circle, and draw a pizza slice in it. The angle parameter is the angle of the slice, and the robot traverses along the crust. A negative angle makes it traverse the circle in the other way, just like using a negative angle in a normal turn command. So it is going to traverse along the pizza slice crust the other way, thus ‘in reverse’. For the negative radius the situation is similar, but we should add a diagram to the docs indeed. You can avoid this though - using the negative angle is more intuitive. |
Beta Was this translation helpful? Give feedback.
-
|
I have to agree with @UnusualJustin here. So, having started to write a test program for all the methods in the DriveBase class, (as part of The method itself works really well and surprisingly accurate with the SPIKE platform. It is currently set up as follows: So as it currently exists, for driving the midpoint of the robot's wheelbase one full loop around a 24cm/240mm circle, the code works as follows: The non-intuitive part is using a negative value for the radius of the circle. My suggestion is to include a boolean to determine whether the robot is driving clockwise or counter-clockwise and just make the angle dictate whether the robot travelling in a fwd or backward direction. Hence the method becomes .curve(radius, angle, clockwise=True, then=Stop.HOLD, wait=True) What do you think? |
Beta Was this translation helpful? Give feedback.
-
|
I can see the competing interests you are dealing with in terms of efficiency in code vs clarity of instructions vs ease of use. Are the .curve() and .drive() methods meant to behave differently? .curve() seems to be more intuitive. Whilst the +ve and -ve radius is logical around a circle, it is not intuitively obvious that a negative angle creates the CCW movement. However, adding a quick code sample like the following into the method explanation in the docs will help people's understanding. So I can understand why you might choose to stay with the two parameters for the .curve method. However, I'm still stuck with the .drive() method being intuitively wrong. Try a simple remote control program and get the robot to move in reverse and it is completely the opposite to steering a vehicle in the real world. Trying to explain the difference between the two functions: The first two lines of the .curve() code above has the robot complete a clockwise circle, then the second line reverses the robot over the same circle. This seems correct to me. I suspect these might actually switched around on .drive(): "Angle sign determines CW/CCW (just like the drive method turn rate) |
Beta Was this translation helpful? Give feedback.
-
|
Just in case there is a lack of clarity in my responses above. Here is a simple program that best demonstrates an inconsistency between the .curve() and .drive() methods. Changing the radius from +ve to -ve in the .curve() method toggles both the direction (Rev) and the turn direction (CCW). This robot behavior seems the most intuitive and logical to me. If the .drive() function was changed to have the same behavior as the .curve(), it would resolve my perceived problem on issue Make drivebase turns counterclockwise for positive turn_rate when reversing #1191. |
Beta Was this translation helpful? Give feedback.


Uh oh!
There was an error while loading. Please reload this page.
-
I'm currently coaching an FLL team in AL that is just getting started using Pybricks. So far, we've been exploring the capabilities and experimenting with converting some of our existing Scratch programs to Pybricks.
Something that came up recently was the desire to have our robot follow a curve in reverse. We discovered that we could do this if we provided a negative value for the radius parameter. Is this intentional or just a happy accident? It's not documented as a capability as far as I can tell and it's not the most intuitive way to accomplish the action (IMO). If it's not intentional, perhaps offering an optional parameter or an additional method to drive in reverse explicitly. If it is intentional, a comment in the docs could prove helpful to others.
Beta Was this translation helpful? Give feedback.
All reactions