Assembly *GraspGLObjects::CreateVisualTool( double magnifier ) { Assembly *tool = new Assembly(); // Create a set of 'fingers', each of which is a 'capsule' composed of a tube with rounded caps. static int n_fingers = target_balls-1; double radius = finger_ball_radius * magnifier; double length = finger_length * magnifier; double spacing = radius * 2.0; for ( int trg = - n_fingers; trg <= n_fingers ; trg++ ){ // Each finger is a 'capsule' composed of a cylinder that is capped on each end with a sphere. Assembly *finger = new Assembly(); Sphere *sphere = new Sphere( radius ); sphere->SetPosition( 0.0, 0.0, 0.0 ); finger->AddComponent( sphere ); Cylinder *cylinder = new Cylinder( radius, radius, length ); cylinder->SetPosition( 0.0, 0.0, - length / 2 ); finger->AddComponent( cylinder ); sphere = new Sphere( radius ); sphere->SetPosition( 0.0, 0.0, - length ); finger->AddComponent( sphere ); // Space the fingers vertically. finger->SetPosition( 0.0, spacing * trg, 0.0 ); tool->AddComponent( finger ); } SetHandColor( tool, true ); return tool; }
MeterStick::MeterStick( void ) { double stick_radius = 25.0; Cylinder *cylinder; Disk *disk; cylinder = new Cylinder( stick_radius, stick_radius, 200.0 ); cylinder->SetColor( RED ); AddComponent( cylinder ); cylinder = new Cylinder( stick_radius, stick_radius, 200.0 ); cylinder->SetOffset( 0.0, 0.0, 200.0 ); cylinder->SetColor( WHITE ); AddComponent( cylinder ); cylinder = new Cylinder( stick_radius, stick_radius, 200.0 ); cylinder->SetOffset( 0.0, 0.0, 400.0 ); cylinder->SetColor( RED ); AddComponent( cylinder ); cylinder = new Cylinder( stick_radius, stick_radius, 200.0 ); cylinder->SetOffset( 0.0, 0.0, 600.0 ); cylinder->SetColor( WHITE ); AddComponent( cylinder ); cylinder = new Cylinder( stick_radius, stick_radius, 200.0 ); cylinder->SetOffset( 0.0, 0.0, 800.0 ); cylinder->SetColor( RED ); AddComponent( cylinder ); cylinder = new Cylinder( stick_radius / 2.0, stick_radius / 2.0, 100.0 ); cylinder->SetAttitude( 90.0, j_vector ); cylinder->SetColor( BLACK ); AddComponent( cylinder ); cylinder = new Cylinder( stick_radius / 2.0, stick_radius / 2.0, 100.0 ); cylinder->SetAttitude( 90.0, j_vector ); cylinder->SetPosition( 0.0, 0.0, 1000.0 - stick_radius ); cylinder->SetColor( BLACK ); AddComponent( cylinder ); disk = new Disk( stick_radius ); disk->SetPosition( 0.0, 0.0, 990.0 ); disk->SetColor( RED ); AddComponent( disk ); }
Assembly *GraspGLObjects::CreateKinestheticTool( void ) { static const double hand_radius = finger_ball_radius * 2.5; Assembly *finger = new Assembly(); Sphere *sphere = new Sphere( hand_radius ); sphere->SetPosition( 0.0, 0.0, 0.0 ); finger->AddComponent( sphere ); Cylinder *cylinder = new Cylinder( hand_radius, hand_radius, finger_length ); cylinder->SetPosition( 0.0, 0.0, - finger_length / 2 ); finger->AddComponent( cylinder ); sphere = new Sphere( hand_radius ); sphere->SetPosition( 0.0, 0.0, - finger_length ); finger->AddComponent( sphere ); // Set a default color. I like blue. // In K-K color will be varied according to the orientation error. finger->SetColor( 0.0, 0.0, 1.0, 1.0 ); return finger; }
// The following objects are not used during the Grasp protocol and are not seen by the subject. // Rather, these objects are used in the GraspGUI and elswhere to visualize the subject's pose. // Perhaps they would be better placed in another class so that they are not included when not needed. Assembly *GraspGLObjects::CreateHead( void ) { Assembly *head = new Assembly(); // Skull Ellipsoid *skull = new Ellipsoid( head_shape ); skull->SetColor( .4f, 0.0f, .4f ); // Eyes head->AddComponent( skull ); Sphere *sphere = new Sphere( 20.0 ); sphere->SetColor( 0.0f, 0.0f, 1.0f ); sphere->SetPosition( -50.0, 20.0, -100.0 ); head->AddComponent( sphere ); sphere = new Sphere( 20.0 ); sphere->SetColor( 0.0f, 0.0f, 1.0f ); sphere->SetPosition( 50.0, 20.0, -100.0 ); head->AddComponent( sphere ); // Nose Cylinder *cylinder = new Cylinder( 20.0, 5.0, 30.0 ); cylinder->SetPosition( 0.0, -20.0, - head_shape[Z] ); cylinder->SetOrientation( 0.0, 90.0, 0.0 ); cylinder->SetColor( YELLOW ); head->AddComponent( cylinder ); return head; }
Assembly *GraspGLObjects::CreateOrientationTarget( void ) { Assembly *target = new Assembly(); if ( useBars ) { for (int trg = - target_bars ; trg <= target_bars ; trg++ ){ Cylinder *cylinder = new Cylinder( target_bar_radius, target_bar_radius,2.0 * room_radius ); cylinder->SetPosition( 0.0 + target_bar_spacing * trg, 0.0, 0.0 ); cylinder->SetOrientation(0.0, 90.0, 0.0); cylinder->SetColor( Translucid( BLUE ) ); target->AddComponent( cylinder ); } } else { for (int trg = - target_balls ; trg <= target_balls ; trg++ ){ Sphere *sphere = new Sphere( target_ball_radius ); sphere->SetPosition( 0.0, 0.0 + target_ball_spacing * trg, 0.0 ); sphere->SetColor(( 255.0 - abs(trg) * 50.0 ) / 255.0, 0.0, 0.0); target->AddComponent( sphere ); } } return target; }