Skip to content

Conversation

Chachay
Copy link
Contributor

@Chachay Chachay commented Mar 20, 2020

  • Utilize scipy module to reduce internal dependency (cubic spline)
  • Reduce high context parameters in rear_wheel_feedback_control function

Other proposal (not implemented):

  • Speed profile is disabled; could direction switching be decided at line 143? this would be closer to real-world implementation.
  • pi_2_pi could also be replaced to numpy unwrap; though I think it is not so effective on readability.

@lgtm-com
Copy link

lgtm-com bot commented Mar 20, 2020

This pull request introduces 2 alerts when merging 7473907 into 4093b64 - view on LGTM.com

new alerts:

  • 1 for Unused local variable
  • 1 for Unused import

@AtsushiSakai AtsushiSakai self-requested a review March 23, 2020 11:40
@AtsushiSakai
Copy link
Owner

@Chachay Thank you for your PR!!. It looks simpler. Please fix some minor points to merge as below.

@AtsushiSakai
Copy link
Owner

Please fix the issues reported by lgtm-com.

Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL.


self.length = s[-1]

def yaw(self, s):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calc_yaw is better? function should be start by a verb.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

dx, dy = self.dX(s), self.dY(s)
return np.arctan2(dy, dx)

def curvature(self, s):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

calc_curvature?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

ddx, ddy = self.ddX(s), self.ddY(s)
return (ddy * dx - ddx * dy) / ((dx ** 2 + dy ** 2)**(3 / 2))

def __findClosestPoint(self, s0, x, y):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use snake-case based on pep8.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

return (ddy * dx - ddx * dy) / ((dx ** 2 + dy ** 2)**(3 / 2))

def __findClosestPoint(self, s0, x, y):
def f(_s, *args):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the function name more explicit?

_x, _y= self.X(_s), self.Y(_s)
return (_x - args[0])**2 + (_y - args[1])**2

def jac(_s, *args):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make the function name more explicit?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

named calc distance & its jacobian

minimum = optimize.fmin_cg(f, s0, jac, args=(x, y), full_output=True, disp=False)
return minimum

def TrackError(self, x, y, s0):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be calc_track_error


return e, k, yaw, s

def PIDControl(target, current):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change pid_control

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed

self.yaw = self.yaw + self.v / L * math.tan(delta) * dt
self.v = self.v + a * dt

class TrackSpline:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CubicSplinePath is better?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed

Chachay added 2 commits March 23, 2020 16:00
- rename functions
- add target speed controller (as the substitute of calc speed profile)
- remove unnecessary else case
@Chachay
Copy link
Contributor Author

Chachay commented Mar 24, 2020

Thank you for your review. I added "switching direction" in addition to the function name fixes.

Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL

target_speed = 10.0 / 3.6

sp = calc_speed_profile(cx, cy, cyaw, target_speed)
track = CubicSplinePath(ax, ay)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

track -> cubic_spline_path ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couldn't this object be better to have the name detached from the interpolation method?

Copy link
Owner

@AtsushiSakai AtsushiSakai Mar 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this object mean a spline path object? What do you imply the "track" name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant the name could be any of reference_track, reference_path, target_track and target_path or even only path or track, but it isn't necessary to be cubic spline as long as class C2.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh ok. I got it. i feel reference_path is better.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed.

Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PTAL

ind, e = calc_nearest_index(state, cx, cy, cyaw)

k = ck[ind]
def rear_wheel_feedback_control(state, e, k, yaw_r):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yaw_r -> yaw_ref ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will rename this

Copy link
Owner

@AtsushiSakai AtsushiSakai left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!!

@AtsushiSakai AtsushiSakai merged commit 9274aac into AtsushiSakai:master Mar 26, 2020
@Chachay Chachay deleted the MPC branch March 29, 2020 20:14
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

Successfully merging this pull request may close these issues.

2 participants