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

Update for student code #5

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

Conversation

josetoribio
Copy link

No description provided.

@Tuxliri
Copy link

Tuxliri commented May 19, 2023

@josetoribio does this work on both the drone and the lx? I see several print statement which cannot work in Python 3, did you test in the lx?

@Tuxliri
Copy link

Tuxliri commented May 19, 2023

Also since we are using this in the lx we need to add a __main__.py file to import it as a module and we should remove the files for visualization which have been incorporated in the lx notebooks.

Copy link

@Tuxliri Tuxliri left a comment

Choose a reason for hiding this comment

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

See comments in files and PR for changes to make.

from cv_bridge import CvBridge, CvBridgeError
from geometry_msgs.msg import PoseStamped
from pidrone_pkg.msg import State
from localization_helper import LocalizationParticleFilter, create_map, PROB_THRESHOLD
Copy link

Choose a reason for hiding this comment

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

Why are we importing these from the localization_helper and not from student_localization_helper?

x, y, z, w = tf.transformations.quaternion_from_euler(0, 0, self.pos[3])
self.posemsg.pose.position.x =
self.posemsg.pose.position.y =
self.posemsg.pose.position.z =
Copy link

Choose a reason for hiding this comment

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

Anytime we do not assign something that we want the student to fill we should set it = ....



def is_almost_equal(x, y):
epsilon = 1e-8
epsilon = 1*10**(-8)
Copy link

Choose a reason for hiding this comment

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

These are equivalent but it's best to leave 1e-8


# cannot find a match
if len(poses) == 0:
print "Random Initialization"
Copy link

Choose a reason for hiding this comment

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

If we are using this file in the lx notebook we need to change all these print "blablabla" directives to print("blablabla").

Comment on lines +423 to +431
"""""
keeps angle within -pi to pi
"""""
while angle > math.pi:
angle -= 2 * math.pi
while angle <= -math.pi:
angle += 2 * math.pi

return angle
Copy link

Choose a reason for hiding this comment

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

this can be replaced by return ( angle + np.pi) % (2 * np.pi ) - np.pi

Comment on lines -255 to -285
##############################################################################
# TODO implement this method to update the map for FastSLAM!
#
# if this particle has no landmarks:
# add every currently observed feature as a landmark
# adjust particle's weight to reflect the change in certainty from adding landmarks
# else:
# close landmarks = list of particle's landmarks within self.perceptual_range of the particle's pose
# if close landmarks is not empty:
# part_descriptors = list of landmark.des for each landmark in close_landmarks
# matched_landmarks = boolean list with same length as close_landmarks, set to false
#
# for each observed feature:
# if part_descriptors is not empty:
# match = self.matcher.knnMatch(np.array([des]), np.array(part_descriptors), k=2)
#
# if there was not match or the match is poor quality:
# add the feature as a new landmark
# adjust particle weight to reflect the change in certainty
# else:
# use match.trainIdx to find the index of the matching landmark in the map
# set the boolean corresponding to this landmark in matched_landmarks to true
# update the landmark in particle.landmarks with information from the newly
# observed feature*
# update the weight of the particle to reflect the quality of the match
# hint: use scale_weight
#
# * this step is the most tricky because the index of the landmark in the close_landmarks list
# is not the same as its index in particle.landmarks! This is because close_landmarks only
# contains some of the landmarks in particle.landmarks
##############################################################################
Copy link

Choose a reason for hiding this comment

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

This kind of pseudocode could be helpful for students, I would keep it otherwise it's a lot of work to think about everything from scratch.

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