Skip to content
This repository has been archived by the owner on Apr 14, 2020. It is now read-only.

Inverting for futaba type servos #5

Closed
mano1979 opened this issue May 10, 2017 · 2 comments
Closed

Inverting for futaba type servos #5

mano1979 opened this issue May 10, 2017 · 2 comments

Comments

@mano1979
Copy link

i need to invert the direction of all servos. Mine go CCW as yours go CW.

Where can i change the direction for the entire kinematics?
in the basic code that i used before the kinematics looked something like this:

knee = value1

and i would change it to:

knee = 180 - value1 // 180 is the max posible value

Is there a file where i can do the same? What file is used for writing the values to i2c?

@mithi
Copy link
Owner

mithi commented May 28, 2017

Hi,

@mano1979 sorry for the late reply. I haven't had the time to update repository.

The file used for writing the values to i2c is here in this folder
https://github.com/mithi/hexy/tree/master/hexy/comm
you can check Adafruit's documentation for more information
https://learn.adafruit.com/16-channel-pwm-servo-driver

There are many ways to solve this:

  1. If you need to invert the directions of ALL the servos, here's what you can do.

If you take a look at this file:
https://github.com/mithi/hexy/blob/master/hexy/robot/core.py
in class Joint lines 137-143:

It has this function: Where it constraints the angle from it's minimum and maximum angle values in degrees and then proceeds to remap the angle the minimum and maximum pulse sent to the
i2c driver. you can insert the line angle = 180 - angle there.

You can check the classes HexapodCore, Leg and Joint classes
They're fairly straight forward and easy to modify to get what you need.

    def pose(self, angle = 0):

        angle = constrain(angle, -(self.max + self.leeway), self.max + self.leeway)
        pulse = remap(angle, (-self.max, self.max), (self.min_pulse, self.max_pulse))

        drive(self.channel, pulse)
        self.angle = angle

You may need to calibrate na minimum and maximum values of the pulses for each servo in lines 4 - 19 of the same file IE do the calibrations as detailed here:
https://learn.adafruit.com/16-channel-pwm-servo-driver

""" joint_key convention:
    R - right, L - left
    F - front, M - middle, B - back
    H - hip, K - knee, A - Ankle
    key : (channel, minimum_pulse_length, maximum_pulse_length) """

joint_properties = {

    'LFH': (0, 248, 398), 'LFK': (1, 188, 476), 'LFA': (2, 131, 600),
    'RFH': (3, 275, 425), 'RFK': (4, 227, 507), 'RFA': (5, 160, 625),
    'LMH': (6, 312, 457), 'LMK': (7, 251, 531), 'LMA': (8, 138, 598),
    'RMH': (9, 240, 390), 'RMK': (10, 230, 514), 'RMA': (11, 150, 620),
    'LBH': (12, 315, 465), 'LBK': (13, 166, 466), 'LBA': (14, 140, 620),
    'RBH': (15, 320, 480), 'RBK': (16, 209, 499), 'RBA': (17, 150, 676),
    'N': (18, 150, 650)
}
  1. You can solve this the way @patrickpoirer did by adding what he calls a
    symmetric parameter in the joint parameters
    See the issue he submitted Add asymmetric parameter  #3

  2. Or you can check out @robottwo's fork instead (which I haven't had time to test)
    https://github.com/mithi/hexy/pull/2/files

Did this answer your question? Let me know so I can close it if so. Thanks!

@mithi
Copy link
Owner

mithi commented May 29, 2017

Hi @mano1979 I've updated the README, let me know if you find it helpful, thanks!
https://github.com/mithi/hexy/blob/master/README.md

@mithi mithi closed this as completed May 29, 2017
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants