Skip to content
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

How do I change the turning radius? #4

Open
ferreirajoaouerj opened this issue Mar 17, 2022 · 4 comments
Open

How do I change the turning radius? #4

ferreirajoaouerj opened this issue Mar 17, 2022 · 4 comments

Comments

@ferreirajoaouerj
Copy link

Thank you for making this package available! How do I change the maximum turning radius?

@nathanlct
Copy link
Owner

Thanks for your interest!

There is no option to change it right now. The original paper only prescribes turning around a unit circle (eg. a circle of radius 1). Maybe there are some papers since then that compute the formulas for arbitrary radiuses.

Looking at the formula for path1 for instance:

u, t = R(x - math.sin(phi), y - 1 + math.cos(phi))

I didn't doublecheck this but I believe to get a radius of size rho, you would do

u, t = R(x - math.sin(phi), y + rho * (- 1 + math.cos(phi)))

Which might need a bit more work derivating for the other formulas but definitely doable with some time.

Hope this helps!

@memo1400
Copy link

memo1400 commented May 4, 2022

@ferreirajoaouerj @nathanlct do you have a solution now for changing the turning radius?

@nathanlct
Copy link
Owner

@memo1400 I did not work on this on my end.

Just thinking of this now but wouldn't it work to scale all the points then scale them back?

ie. multiply all initial (x,y) coordinates by rho, compute the paths with the current code (ie a turning radius of 1) then divide the paths by rho and you would get paths with a turning radius of 1/rho (just a thought, don't have time to verify this right now)

@limdingwen
Copy link

@memo1400 I did not work on this on my end.

Just thinking of this now but wouldn't it work to scale all the points then scale them back?

ie. multiply all initial (x,y) coordinates by rho, compute the paths with the current code (ie a turning radius of 1) then divide the paths by rho and you would get paths with a turning radius of 1/rho (just a thought, don't have time to verify this right now)

This works, thank you! For reference, this is my code:

# Converts our node to RS library's node
def node_us_to_rs(r, source):
    (source_x, source_y), source_angle = source
    rho = 1 / r
    return source_x * rho, source_y * rho, degrees(source_angle)


# Converts a PathElement to a Movement
def convert_path_element_to_movement(r, element):
    rho = 1 / r
    if element.steering is Steering.STRAIGHT:
        return Straight(DEFAULT_SPEED if element.gear is Gear.FORWARD else -DEFAULT_SPEED, element.param / rho)
    else:
        return Curve(DEFAULT_SPEED if element.gear is Gear.FORWARD else -DEFAULT_SPEED, element.param *
                     (1 if element.steering is Steering.RIGHT else -1))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants