 
{ File ld.sil -  ( Load function for Silspec ) }
 
 
{ This is the "load" function for this robot.  It is called when
  a robot of this type is Installed into the workcell. }
 
procedure load_nj4_270_27(name: string);
var
  rob: shape; rd: robotdata;
  flange : model;
  flange_name : string;
  irob : iterative_robot;
  jlr : joint_limited_robot;
  vlims : joint_kinds;
  jlims : jvr_bnds;
begin
  nj4_270_27_robot_model := restore(nj4_270_27_robot_pathname);
  add(set_kind(nj4_270_27_robot_model,"device),name);
  c_ob(select(wlkup(name),"LINKN));
  dset_pathdata_of(c_ob(),copy(nj4_270_27_pathdata) as_type universal);
  dset_jsi_zone_mode(c_ob(),FALSE);
  dset_fly_value(c_ob(),1.000000000000000e+000);
  dset_zone_mode(c_ob(),FALSE);
  dset_fly_value(c_ob(),1.000000000000000e+000);
  dset_objectdata_of(parent(c_ob()),copy(nj4_270_27_robotdata) as_type universal);

{ Support New Parameters for Calibration Package }

  rob:= wlkup(name);
  irob := [rob] as iterative_robot;
  itsol_fast(rob,true);
  jlims := mk_jvr_bnds(       [-3.141592653589794e+000, 3.141592653589794e+000] as rbnds,
       [-2.879793265790642e+000, -2.617993877991458e-001] as rbnds,
       [-3.141592653589803e+000, 3.141592653589787e+000] as rbnds,
       [-1.919862177193765e+000, 5.061454830783556e+000] as rbnds,
       [-3.490658503988814e-001, 6.632251157578440e+000] as rbnds,
       [-3.490658503988660e+000, 3.490658503988660e+000] as rbnds);
  vlims := mk_joint_kinds(FALSE,FALSE,TRUE,FALSE,FALSE,FALSE);
  jlr := [rob,vlims,jlims] as joint_limited_robot;
  rd:= robotdata_of(rob);
  dset_robot_constants_of(rd,(copy(nj4_270_27_constants as_type ob) as_type robot_constants) as_type universal);
  allocate_new_parms(rob,3,5,0);
  dset_rob_u_parm(rob,0,'' as_type universal);
  dset_rob_u_parm(rob,1,list("jzero,"azero                      ) as_type universal);
  dset_rob_u_parm(rob,2,emptylist(rob_parm_id) as_type universal);
  dset_joint_r_parm(rob,4,0,0.000000000000000e+000);
  dset_joint_r_parm(rob,4,1,4.600000000000000e+001);
  dset_joint_r_parm(rob,4,2,1.050000000000000e+002);
  dset_joint_r_parm(rob,4,3,2.500000000000000e+001);
  dset_joint_r_parm(rob,4,4,0.000000000000000e+000);
  dset_joint_r_parm(rob,4,5,0.000000000000000e+000);
  c_ob(rob);
 
  dset_jlims_reduction(c_ob(),0.0);
  assert_kind(select(c_ob(),"LINK0),"rigid_link);
  assert_kind(select(c_ob(),"LINK1),"rigid_link);
  assert_kind(select(c_ob(),"LINK2),"rigid_link);
  assert_kind(select(c_ob(),"LINK3),"rigid_link);
  assert_kind(select(c_ob(),"LINK4),"rigid_link);
  assert_kind(select(c_ob(),"LINK5),"rigid_link);
  assert_kind(select(c_ob(),"LINKN),"rigid_tool);
  assert_kind(select(c_ob(),"ACT3),"rigid_link);
  c_ob(select(wlkup(name),"ACT3));
  assert_kind(select(c_ob(),"CRNK),"rigid_link);
  assert_kind(select(c_ob(),"CPLR),"rigid_link);
  assert_kind(select(rob,'LINK2/PASSIVE1'),"rigid_link);
  assert_kind(select(rob,'LINK1/PASSIVE1'),"rigid_link);
  c_ob(select(wlkup(name),"LINKN));
  move_robot_nj4_270_27(c_ob(),home(parent(c_ob())));
  flange:= mk_empty_shape();
  flange_name := concat(uppercase(name),'_FLANGE');
  if object_exists(flange_name) then delete(flange_name);
  add(flange,flange_name);
  imoveto(flange, nj4_270_27_flange_rel_wrist rel pose(c_ob()));
  affix(wlkup(flange_name),c_ob());
  c_ob(wlkup(flange_name));
{ Here we should load the silio if it is present.... }
  repaint();
end;
  
  
robot_load_functions := cons(list('NJ4_270_27' as_type universal,
                           mk_closure(load_nj4_270_27(string)) as_type universal),
                           robot_load_functions);
  
if not(member('NJ4_270_27', installed_robots)) then
   installed_robots := cons('NJ4_270_27', installed_robots);
  
