-
Notifications
You must be signed in to change notification settings - Fork 7
Chain
A Tharp chain will Wrap the actuators so that we have all the info and methods we need to define and solve for our the kinematic chain.
@param {Object} opts Options
- opts.actuators {Servos, Servo.Array, Array of Servo Objects, or a Servos initialization array} The object or device array that contains the chain's actuators, or an array of Servo opts to create a new Servos() object [Required]
- opts.chainType {String}: One of the pre-defined leg types described in the readme. Don't see your system type? Open an issue, or better yet make a Pull Request! [Required]
- opts.segments {Object}: An object with the segment names and lengths for our system. These names vary with the chainType [Required]
- opts.origin {Object}: The x, y and z offset of the chain's origin point from the robot's origin point. [Optional. Default: [{x: 0, y:0 , z: 0}] ]
- opts.position {Object}: The initial x, y and z position of the chain's end effector. [Optional. Default: [{x: 0, y:0 , z: 0}] ]
- opts.require {Boolean}: If true then calls to Robot.render() will error if this chain cannot be solved for the given position. [Optional. Default: true]
returns this Chain()
Example:
var frontRight = new tharp.Chain({
actuators: [
{pin:40, offset: 24, startAt: 0, range: [0, 90] },
{pin:39, offset: 87, startAt: 78, range: [-80, 78] },
{pin:38, offset: 165, invert: true, startAt: -140, range: [-160, -10] }
],
chainType: "CoxaY-FemurZ-TibiaZ",
origin: { x: 4.25, y: 2.875, z: 8.15],
segments: { femur: 7.6125, tibia: 10.4 }
});
Move all the servos so the end effector is at the target position. In most cases you would want to call Chain.solve() on all your chains and make sure they can all reach the desired end effector position before rendering the movement. Tharp.Robot can handle this extra step for you so you should not need to use Chain.render()
directly.
@param {Object} opts Options: {[x][, y][, z]}
- opts.x {Number}: The desired position of the end effector along the x axis [Optional].
- opts.y {Number}: The desired position of the end effector along the y axis [Optional].
- opts.z {Number}: The desired position of the end effector along the z axis [Optional].
returns this Chain()
Example:
frontRight.render({
position: { x: 12.5, y: -4, z: 8.2 }
});
Find the angles needed to position the end effector at a desired point. The angles are written to chain.position.
@param {Object} opts Options: {[x][, y][, z]}
- opts.x {Number}: The desired position of the end effector along the x axis [Optional].
- opts.y {Number}: The desired position of the end effector along the y axis [Optional].
- opts.z {Number}: The desired position of the end effector along the z axis [Optional].
Returns array of angles (in radians) or position
Example:
var angles = frontRight.solve({
position: { x: 12.5, y: -4, z: 8.2 }
});
// returns th[0.4, -0.2, 0.8]
Find an end effector's position relative to the kinematic chain origin
- @param {Object} opts Options: {position[, origin][, orientation] }
- opts.position {Object} position: {[x][, y][, z]} The end effector position relative to the robots origin point
- opts.origin {Object}: origin: {[x][, y][, z]} The kinematic chain origin relative to the robots origin point
- opts.orientation {Object}: orientation: {[pitch][, roll][, yaw]} pitch, roll and yaw given in radians
returns a position {x, y, z}
Example:
var offset = frontRight.eePosition({
position: { x: 12.5, y: -4, z: 8.2 }
});
// returns { x: 8.25, y: -1.125, z: 0.05],
Position sets the end effector position in global coordinate space.
- Chain.position.x - The position of the end effector on the x axis
- Chain.position.y - The position of the end effector on the y axis
- Chain.position.z - The position of the end effector on the z axis