public class Grasp
extends java.lang.Object
Arm IK and grasping demo (CS4610 LAB3 and 4 solution).
ikDemo()
is the top-level driver for interactive arm IK (LAB3 part
one).
graspDemo(float, float)
is the top-level driver for blind world-fram grasping
(LAB3 part two).
Many of the component functions are also available for use independently.
Modifier and Type | Field and Description |
---|---|
static float |
ARM_OFFSET
Radial offset in mm from robot frame origin to grip point.
|
protected boolean |
armEnabled
Whether arm is enabled.
|
float |
d
Increment amount in mm for
ikDemo() . |
static float |
D_INCR
Default increment amount in mm for
ikDemo() . |
static float |
D_MAX
Increment limits in mm for
ikDemo() . |
static float |
D_MIN
Increment limits in mm for
ikDemo() . |
static float |
EE_TOL
EE position tolerance in mm.
|
float |
grip
Gripper state.
|
float |
gx_r
Grip point location in mm in robot frame.
|
float |
gx_w
Target location in world mm.
|
float |
gy_w
Target location in world mm.
|
float |
gz_r
Grip point location in mm in robot frame.
|
float |
gz_w
Target location in world mm.
|
static float[] |
HOME
Home pose joint angles.
|
static float |
HOME_TO_GRIP
Extension distance in mm from home to grip.
|
static float |
HOME_TO_GROUND
Extension distance in mm from home to ground.
|
static float |
INTERP_SPEED
EE interpolation speed in mm/sec for
interpolateArm(float, float) . |
static float |
L0
Arm constants in mm.
|
static float |
L1
Arm constants in mm.
|
OHMMDrive |
ohmm
The
OHMMDrive object. |
static float |
PI
Float cover of Math constant.
|
static java.lang.String |
RXTX_PORT
RXTX port filename.
|
static float[] |
SALUTE
Salute pose joint angles.
|
static float[] |
STOW_DOWN
Stow joint angles.
|
static float[] |
STOW_UP
Stow joint angles.
|
protected boolean |
stowUp
Whether next stow should be in up position.
|
private static java.lang.String |
svnid |
static float |
SX
Arm constants in mm.
|
static float |
SZ
Arm constants in mm.
|
static float |
T0_MAX
Joint angle limits in rad.
|
static float |
T0_MIN
Joint angle limits in rad.
|
static float |
T1_MAX
Joint angle limits in rad.
|
static float |
T1_MIN
Joint angle limits in rad.
|
static float |
T2_MAX
Joint angle limits in rad.
|
static float |
T2_MIN
Joint angle limits in rad.
|
float[] |
theta
Arm joint angles in rad.
|
static float |
THETA_TOL
Joint angle tolerance in rad.
|
float |
thetaYaw
Robot orientation in rad.
|
static java.lang.String |
USAGE
Usage message.
|
static float |
WX
Arm constants in mm.
|
static float |
WZ
Arm constants in mm.
|
float[] |
xyt
Robot pose in world frame.
|
Constructor and Description |
---|
Grasp()
|
Grasp(OHMMDrive ohmm)
Inits
ohmm . |
Modifier and Type | Method and Description |
---|---|
static float |
abs(float t)
float cover of eponymous Math API
|
void |
armFK()
Covers
armFK(boolean) , always local. |
void |
armFK(boolean local)
Update fields from current hardware state.
|
boolean |
armIK()
Covers
armIK(boolean) , always local. |
boolean |
armIK(boolean local)
Update joint angle fields from target pose fields.
|
void |
armWait()
Block until arm motion completes.
|
static float |
atan2(float y,
float x)
float cover of eponymous Math API
|
void |
cal()
Similar to
home(boolean) but goes to calibration pose. |
static float |
cos(float t)
float cover of eponymous Math API
|
static int |
div(int n,
int d)
float division with rounding
|
void |
driveWait()
Block until drive motion completes.
|
void |
dumpArm()
|
static java.lang.String |
fmt(float f)
format a float
|
static java.lang.String |
fmt(float[] f)
covers
fmt(float, float, float) |
static java.lang.String |
fmt(float x,
float y,
float z)
format three float
|
void |
graspDemo(float x,
float y)
Runs the grasping demo.
|
void |
home()
Covers
home(boolean) , always local. |
void |
home(boolean local)
Home the arm, then
armFK(boolean) . |
void |
ikDemo()
Runs the interactive ik demo.
|
void |
ikHelp()
Show interactive help for interactive IK.
|
void |
init()
Disable drive orientation servo, reset hardware odomery, reinit and
enable arm hardware, and
home(boolean) (global). |
void |
interpolateArm(float dx,
float dz)
Interpolate vertical plane arm motion along a line in task space.
|
static void |
main(java.lang.String[] argv)
Demo driver, see
USAGE . |
static float |
max(float y,
float x)
float cover of eponymous Math API
|
static float |
min(float y,
float x)
float cover of eponymous Math API
|
void |
orientAndWait(float toTheta)
Yaw robot and wait for motion to finish.
|
static int |
parseInt(java.lang.String s)
convienence to parse an int
|
static void |
print(java.lang.String s)
convenience to print to System.out
|
static void |
println(java.lang.String s)
convenience to print to System.out
|
void |
salute()
Salute the arm, then
armFK(boolean) . |
static float |
sign(float t)
get float sign
|
static float |
sin(float t)
float cover of eponymous Math API
|
static float |
sqrt(float f)
float cover of eponymous Math API
|
void |
stow()
Covers
stow(boolean) , down. |
void |
stow(boolean up)
Stow the arm, then
armFK(boolean) . |
static float |
toDeg(float t)
float cover of eponymous Math API
|
static float |
toRad(float t)
float cover of eponymous Math API
|
void |
updateArm()
Covers
updateArm(boolean, boolean) , always local, no spew. |
void |
updateArm(boolean spew)
Covers
updateArm(boolean, boolean) , always local. |
void |
updateArm(boolean local,
boolean spew)
armIK(boolean) then set arm hardware to the new theta . |
private static final java.lang.String svnid
public static final java.lang.String USAGE
public static final float PI
public static final java.lang.String RXTX_PORT
public static final float THETA_TOL
public static final float EE_TOL
public static final float INTERP_SPEED
interpolateArm(float, float)
.public static final float T0_MIN
public static final float T0_MAX
public static final float T1_MIN
public static final float T1_MAX
public static final float T2_MIN
public static final float T2_MAX
public static final float[] HOME
public static final float[] SALUTE
public static final float[] STOW_UP
public static final float[] STOW_DOWN
public static final float SX
public static final float SZ
public static final float L0
public static final float L1
public static final float WX
public static final float WZ
public static final float D_INCR
ikDemo()
.public static final float D_MAX
ikDemo()
.public static final float D_MIN
ikDemo()
.public static final float HOME_TO_GROUND
public static final float HOME_TO_GRIP
public static final float ARM_OFFSET
public float d
ikDemo()
.public float thetaYaw
public float[] theta
public float gx_r
public float gz_r
public float gx_w
public float gy_w
public float gz_w
public float[] xyt
public float grip
protected boolean armEnabled
protected boolean stowUp
public static void main(java.lang.String[] argv) throws java.io.IOException
USAGE
.java.io.IOException
public void ikDemo()
public void graspDemo(float x, float y)
x
- target x location in world frame mmy
- target y location in world frame mmpublic void ikHelp()
Show interactive help for interactive IK.
public void dumpArm()
public void orientAndWait(float toTheta)
Yaw robot and wait for motion to finish.
public void interpolateArm(float dx, float dz)
Interpolate vertical plane arm motion along a line in task space.
dx
- change in EE x position in robot frame mmdz
- change in EE z position in robot frame mm
The interpolation starts at the current EE location (gx_r
,
gz_r
) in robot frame (updated by a call to armFK(boolean)
, local
FK) and proceeds at INTERP_SPEED
mm/sec.
public void armWait()
public void driveWait()
public void home(boolean local)
Home the arm, then armFK(boolean)
.
local
- whether to home only the arm joints (local) or also to
include the robot yaw (global)public void home()
home(boolean)
, always local.public void cal()
home(boolean)
but goes to calibration pose.public void stow(boolean up)
Stow the arm, then armFK(boolean)
.
up
- whether to stow in up positionpublic void stow()
stow(boolean)
, down.public void salute()
Salute the arm, then armFK(boolean)
.
public void init()
Disable drive orientation servo, reset hardware odomery, reinit and
enable arm hardware, and home(boolean)
(global).
public void updateArm(boolean local, boolean spew)
armIK(boolean)
then set arm hardware to the new theta
.public void updateArm(boolean spew)
updateArm(boolean, boolean)
, always local.public void updateArm()
updateArm(boolean, boolean)
, always local, no spew.public void armFK(boolean local)
Update fields from current hardware state.
Always updates theta
from the hardware, then gx_r
,
gz_r
.
Global FK also updates xyt
from hardware odometry, then thetaYaw
, gx_w
, gy_w
, gz_w
.
local
- whether to do local FK, else globalpublic void armFK()
armFK(boolean)
, always local.public boolean armIK(boolean local)
Update joint angle fields from target pose fields.
Updatestheta
from
Global IK also updates xyt
from hardware odometry, then gx_r
, gz_r
and thetaYaw
.
local
- whether to do local IK, else globalpublic boolean armIK()
armIK(boolean)
, always local.public static float toDeg(float t)
public static float toRad(float t)
public static float sqrt(float f)
public static float cos(float t)
public static float sin(float t)
public static float abs(float t)
public static float sign(float t)
public static int div(int n, int d)
public static float atan2(float y, float x)
public static float max(float y, float x)
public static float min(float y, float x)
public static java.lang.String fmt(float f)
public static java.lang.String fmt(float x, float y, float z)
public static java.lang.String fmt(float[] f)
fmt(float, float, float)
public static void println(java.lang.String s)
public static void print(java.lang.String s)
public static int parseInt(java.lang.String s) throws java.lang.NumberFormatException
java.lang.NumberFormatException