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

Improve code quality of 4 specific modules #47

Closed
4 tasks done
mithi opened this issue Apr 13, 2020 · 2 comments
Closed
4 tasks done

Improve code quality of 4 specific modules #47

mithi opened this issue Apr 13, 2020 · 2 comments
Labels
code quality Ideas on how to improve code quality PRIORITY This should be addressed first

Comments

@mithi mithi added code quality Ideas on how to improve code quality PRIORITY This should be addressed first labels Apr 13, 2020
@mithi
Copy link
Owner Author

mithi commented Apr 13, 2020

hexapod.models.VirtualHexapod()

When the right middle coxia is twisted the whole hexapod twists
is related to this

            # new alpha pose
            try:
                new_hip_angle = poses[leg_id]["coxia"]
            except KeyError:
                try:
                    new_hip_angle = poses[str(leg_id)]["coxia"]
                except KeyError:
                    new_hip_angle = 0

Currently, it's like this:

        legs, self.n_axis, height = get_legs_on_ground(self.legs)
        self.ground_contacts = [leg.ground_contact() for leg in legs]

        # This means that the position is stable
        if self.n_axis is not None:
            # tilt and shift the hexapod based on new normal
            frame = frame_to_align_vector_a_to_b(self.n_axis, Point(0, 0, 1))
            self.rotate_and_shift(frame, height)
            self._update_local_frame(frame)

            # Only twist if we computed earlier that at least three hips twisted
            if might_twist:
                twist_frame = find_twist_frame(
                    old_ground_contacts, self.ground_contacts
                )
                self.rotate_and_shift(twist_frame, 0)
        else:
            pass

It should be something like

try:
     legs, self.n_axis, height = get_legs_on_ground(self.legs)
except:
    raise Error('Unstable pose')

self.ground_contacts = [leg.ground_contact() for leg in legs]
# tilt and shift the hexapod based on new normal
frame = frame_to_align_vector_a_to_b(self.n_axis, Point(0, 0, 1))
self.rotate_and_shift(frame, height)
self._update_local_frame(frame)

# Only twist if we computed earlier that at least three hips twisted
if might_twist:
    twist_frame = find_twist_frame(old_ground_contacts,  self.ground_contacts)
    self.rotate_and_shift(twist_frame, 0)

@mithi
Copy link
Owner Author

mithi commented Apr 13, 2020

hexapod.models.VirtualHexapod()

To an independent function which is not a method of hexapod.models.VirtualHexapod

  • I don't thing anyone uses the lists
    self.body_dimensions and self.leg_dimensions maybe we should delete that

  • change _store_body_dimensions() function name to _store_attributes() which is more meaningful

    def _store_body_dimensions(self, f=0, m=0, s=0, a=0, b=0, c=0):

  • hexapod.models.VirtualHexapod.update() could definitely be more elegant

    def update(self, poses):

@mithi mithi closed this as completed Apr 14, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality Ideas on how to improve code quality PRIORITY This should be addressed first
Projects
None yet
Development

No branches or pull requests

1 participant