hexabody

HEXA has six legs and each leg has three joints, including the head joint the
DOF(degree of freedom) is 19.

When animating a movement, duration (ms) will be passed as an argument when the
distance to the new location is known, otherwise speed (cm/s for movements and
degree/s for rotations) will passed. The range of duration is 0 ~ 9999ms. The
duration longer than 9999ms will be set as 9999ms.

All joint and leg positions are points in a Cartesian coordinate system.

Usage

var (
// OverflowSoftLimit error is deprecated.
OverflowSoftLimit error = errors.New("Calculate overflow soft limit")
// OverflowHardLimit error happens when 'CalculateJointDegrees' was called to calculate the joints' degrees with coodinates which represent an unreachable position.
OverflowHardLimit error = errors.New("Calculate overflow hard limit")
// YIsZeroOrNegative error is deprecated.
YIsZeroOrNegative error = errors.New("Y is zero or negative")
// JointNumberNotSupport error happens when 'CalculateJointDegrees' or 'Fit' are called with the count of joints of the legposion is not 3.
JointNumberNotSupport error = errors.New("The joint number is not support")
// WrongGaitType error happens when a wrong gait type was selected with 'SelectGait' function. You can make a reference with the GaitType consts.
WrongGaitType error = errors.New("Wrong gait type.")
// OverflowStepLengthRatio error happens when 'SetStepLength' was called to set the step length when walking. It should be 0-1.
OverflowStepLengthRatio error = errors.New("The step length ratio should be (0, 1].")
// LegPositionInvalid error happens when 'Coordinates' was called to return an invalid coordinate.
LegPositionInvalid error = errors.New("The leg postion is invalid.")
// SelectGaitWhileWalking error happens when changing gait type with walking at the same time.
SelectGaitWhileWalking error = errors.New("Cound not select gait while the hexa is walking.")
)

var ErrJointNumberOverstep = errors.New("Joint number should be 0~2.")

func MoveJoint

MoveJoint rotates specified joint on a leg to a given degree in given duration.
The range of degree is different. The range of NO.0 joint's degree is (35 -
145). The range of NO.1 joint's degree is (10 - 170). The range of NO.2 joint's
degree is (10 - 160).

'ErrLegNumberOverstep' error will be returned if jointNumber is not 0-2.

func WalkingContinuously

type GaitType

type GaitType int

const (
GaitOriginal GaitType = iota// default gait
GaitWave // 5+1 gait, 5 legs stay on the ground and 1 leg raise at the same time
GaitRipple // 4+2 gait, 4 legs stay on the ground and 2 legs raise at the same time
GaitTripod // 3+3 gait, 3 legs stay on the ground and 3 legs raise at the same time
GaitAmble // 4+2 gait, 4 legs stay on the ground and 2 legs raise at the same time, different from GaitRipple.
)

type JointDegree

type JointDegree struct {
Degree float64
Range *JointDegreeRange
}

JointDegree defines the degree and range of rotation of a joint.

func (*JointDegree) Fit

func (j *JointDegree) Fit() *JointDegree

Fit ensures the joint in range, if it is out of range, it will be modified to
the adjacent edge value.

func (*JointDegree) IsValid

func (j *JointDegree) IsValid() bool

IsValid returns whether joint degree is in range.

type JointDegreeRange

type JointDegreeRange struct {
Min float64
Max float64
}

JointDegreeRange defines the range of joint rotation.

type JointDegrees

type JointDegrees []JointDegree

JointDegrees is a slice of JointDegree

func NewJointDegrees

func NewJointDegrees() JointDegrees

NewJointDegrees creates a new JointDegrees.

func (JointDegrees) Fit

func (j JointDegrees) Fit() JointDegrees

Fit ensures the joints in range, if any of them is out of range, it will be
modified to the adjacent edge value.