Skip to content
Donovan Buck edited this page Sep 22, 2015 · 5 revisions

Robot Constructor

Handstand Robot

new Tharp.Robot(opts)

A Tharp Robot() will group chains, give you a single object for managing the robot's orientation and make sure that all required chains can be solved before rendering the movement.

@param {Object} opts Options

  • opts.chains {Array of Tharp.Chains()}: The chains in the robot.
  • opts.robotType {String}: One of the pre-defined robot types. Don't see your robot? Open an issue, or better yet make a Pull Request!
  • opts.orientation {Object} Chassis rotation about the Robot's origin.
  • opts.orientation.roll {Number} Rotation about the Z axis
  • opts.orientation.pitch {Number} Rotation about the X axis
  • opts.orientation.yaw {Number} Rotation about the Y axis
  • opts.offset {Object} Chassis translation relative to the Robot's origin
  • opts.offset.x {Number} Chassis offset on the X axis
  • opts.offset.y {Number} Chassis offset on the Y axis
  • opts.offset.z {Number} Chassis offset on the Z axis

Example:

var myRobot = new tharp.Robot({
  chains: [R1, L1, R2, L2, R3, L3],
  robotType: "hexapod"
});

Robot Methods

Robot.render(opts)

Robot.render() will solve and render (if possible) the chains associated with the robot. You can also update the orientation and offset when calling this method. If any of the required chains do not have a solution, an error will be returned and none of the chains will be rendered.

@param {Object} opts Options

  • opts.orientation {Object} Chassis rotation about the Robot's origin.
  • opts.orientation.roll {Number} Rotation about the Z axis
  • opts.orientation.pitch {Number} Rotation about the X axis
  • opts.orientation.yaw {Number} Rotation about the Y axis
  • opts.offset {Object} Chassis translation relative to the Robot's origin
  • opts.offset.x {Number} Chassis offset on the X axis
  • opts.offset.y {Number} Chassis offset on the Y axis
  • opts.offset.z {Number} Chassis offset on the Z axis

Robot Properties

Robot.offset {x: n, y: n, z: n}

Offset will shift the physical origin point for the robot relative to the origin point for the global coordinate system. This is helpful for making to robot lean or raise up without repositioning the end effectors.

  • Robot.offset.x - Distance to shift on the x axis
  • Robot.offset.y - Distance to shift on the y axis
  • Robot.offset.z - Distance to shift on the z axis

Robot.orientation {pitch: n, roll: n, yaw: n}

Orientation will rotate the robot's axes relative to the global coordinate space without affecting the position of the end effectors. This is useful for making the robot tilt, roll or twist without repositioning the end effectors.

  • Robot.orientation.tilt - Rotation about the x axis in radians
  • Robot.orientation.roll - Rotation about the z axis in radians
  • Robot.orientation.yaw - Rotation about the y axis in radians