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

Shamima/fall2020/recruitment-challenge/submission #4

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Shamima-Ali
Copy link
Collaborator

Implemented the Navigation class.

- def update_current_position(self)
Used the PollSensor method from GPS to update the x, y and z values. The getPos method is then used to return the x, y and z values to the Navigation class.

- def navigate(self)
Created 5 boolean variables that will store the boolean value returned from the Steering methods (move_up, move_down etc.).The boolean variables have been assigned a default value of True so if any of the Steering methods were unsuccessful, the variables will become False. If that happens, the TBM will stop moving and display an error message indicating which direction (x, y or z) it couldn't move to. The current_position will also be updated and compared to the desired_position.
------For moving in the x direction: As long as the desired_position is not equal to 0 or current_position, the TBM will move forwards.
------For moving in the y or z direction: The required y or z positions are found by subtracting the current_position and desired_position. If the required y or z directions are positive, the TBM will move to the right and upwards. It will move in the opposite directions if the required y or z positions are negative.
If all of the actuations are successful, the current_position will be updated and compared to the desired_position.

@colton-smith
Copy link
Member

So I don't forget, I'm gonna mention immediately that it would be a good idea to have the default "Actuation Successful" boolean values as False instead of True, for safety reasons.

Copy link
Member

@colton-smith colton-smith left a comment

Choose a reason for hiding this comment

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

Well done Shamima!

Git Practice:
Branch name - great, follows the requested format
PR Description - great, very descriptive. You could also mention the changes to the top level README.md just so that all your bases are covered and all files changed are noted.
PR Title - great, follows the requested format
Commit Messages - concise and descriptive

Code:
The code is very thorough and shows a lot of thought. There are a few minor things to address, and they are mostly style related.

Importantly:

  • Steering is a type, you want to make sure you are using an instance of the class and not the type
  • You are passing steer left and steer down negative values
  • Pass is a placeholder and should be removed when the method is implemented

Thanks for the submission, you can effect some changes and re-request review if you so desire!

Repository containing all paradigm student group recruiting challenges.
Repository containing paradigm student group recruiting challenges.
Copy link
Member

Choose a reason for hiding this comment

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

You're right, it does sound better without all.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't really mean to make that correction😄 I was just trying out to 'commit' feature on my computer.

@@ -70,23 +70,68 @@ def set_desired_position(self, desired_position):
Note: assume the user will pass in the desired_position parameter when using
the interface
"""

self.desired_position = desired_position

pass
Copy link
Member

Choose a reason for hiding this comment

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

All instances of pass should be removed, they were only placed there as placeholders.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done

@@ -70,23 +70,68 @@ def set_desired_position(self, desired_position):
Note: assume the user will pass in the desired_position parameter when using
the interface
"""

Copy link
Member

Choose a reason for hiding this comment

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

PEP8 - There should not be a blank line following any function/method docstring.

Comment on lines 77 to 78


Copy link
Member

Choose a reason for hiding this comment

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

PEP8 - Python methods should only be separated by a single blank line.

act_request_down = True


""""The TBM will move forward as long as the current position is not
Copy link
Member

Choose a reason for hiding this comment

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

There are 4 quotations here instead of 3

Copy link
Member

Choose a reason for hiding this comment

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

Also, # is preferred for block comments as opposed to """

Comment on lines 92 to 96
act_request_forward = True
act_request_right = True
act_request_left = True
act_request_up = True
act_request_down = True
Copy link
Member

Choose a reason for hiding this comment

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

In python it is uncommon to align things like this, instead a space is usually placed before and after the assignment. This is almost assembly-like.

Ex:
number = 10
position = 11
velocity = 12

Comment on lines 92 to 96
act_request_forward = True
act_request_right = True
act_request_left = True
act_request_up = True
act_request_down = True
Copy link
Member

Choose a reason for hiding this comment

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

Good variable names

equal to the desired position in the x direction. """
if desired_position[0] != 0:
while(current_position[0] != desired_position[0]):
act_request_forward = Steering.move_forward()
Copy link
Member

Choose a reason for hiding this comment

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

Steering is the class type, I think you mean to refer to the Steering instance that is a class field - "steering"

Returns: True if actuation requests were successful, False if not
Note: It may be good to notify the user if something unexpected happens!
"""
""" Assumption: If any actuation is unsuccessful, the TBM will stop moving"""
Copy link
Member

Choose a reason for hiding this comment

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

I think this method is supposed to allow the calling code to stop the TBM in the event that an actuation is unsuccessful

Comment on lines 114 to 115
elif required_y_distance < 0:
act_request_left = Steering.move_left(required_y_distance)
Copy link
Member

Choose a reason for hiding this comment

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

Here, the required distance is negative, indicating you have to move left. However, you are calling move left and passing it this negative value. Depending on the implementation of the move_left method, this could steer the machine right or do nothing. Maybe you can use the abs method to get the magnitude of required_distance.

This comment also applies to the z steering block.

Copy link
Member

@Burke-Daniel Burke-Daniel left a comment

Choose a reason for hiding this comment

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

I've just included a couple of nit-picky comments here, Colton got all the major things I noticed as well. Keep up the good work!

Comment on lines 81 to 82
GPS.pollSensor
self.current_position = GPS.getPos
Copy link
Member

Choose a reason for hiding this comment

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

These are method calls, so the syntax will be:

GPS.pollSensor()
self.current_position = GPS.getPos()

equal to the desired position in the x direction. """
if desired_position[0] != 0:
while(current_position[0] != desired_position[0]):
act_request_forward = Steering.move_forward()
Copy link
Member

Choose a reason for hiding this comment

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

so you are calling the methods in Steering as if they were static methods. In order to call these, you need to call them from the steering object that is owned by the Navigation class, so this would instead look like:

act_request_forward = self.steering.move_forward()

if act_request_forward == False:
print("Unable to move to desired x position")
self.update_current_position
return current_position == desired_position
Copy link
Member

Choose a reason for hiding this comment

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

I like the way you have this, where if actuation fails it will return whether or not we have reached the desired position. Nifty way of doing it!


""""The TBM will move forward as long as the current position is not
equal to the desired position in the x direction. """
if desired_position[0] != 0:
Copy link
Member

Choose a reason for hiding this comment

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

should be self.desired_position[0], as the desired_position variable is a member of the object

Thanks for taking the time to review the code. I made the changes as requested.
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.

3 participants