Re: Problem with Judoka1 Reset Angle

Olivier Michel <[email protected]> Wed, 17 Mar 2004 12:51:50 +0100
Newsgroups gmane.comp.cybernetics.webot.contest
Organization Cyberbotics Ltd.
Message-ID <[email protected]>
Mike,

This is my mistake. The patch I actually created doesn't work properly. 
Here is a modified version which I tested and seems to work fine with 
the evaluation version.

-Olivier

Mike Jost wrote:

>Olivier,
>
>I am using the Windows evaluation version of Webots and passing the reset
>string in the Java function emitter_send( ).  I tried replacing the
>judo_reset_supervisor.exe file in the
>Webots/controllers/judo_reset_supervisior/ directory but it did not reset
>the Judoka1 robot correctly when I executed the emitter_send( ) function.  I
>also tried creating a /controllers/judo_reset_supervisor/ directory in the
>directory where I have my test robots running.
>
>Mike Jost
>
>  
>
>>Mike,
>>Thanks for reporting this problem. It comes from the fact that the
>>judo_reset_supervisor controller retrieves the angle vector at the
>>beginning of the simulation but after a few simulation steps. And since
>>the initial angle for JUDOKA_1 is 0 1 0 0, the physics engine may switch
>>it to something like 1 0 0 0.000002 in the very first simulation steps
>>before the supervisor gets the value. Then, when you apply a rotation
>>with the initial value, the angle vector is wrong... I fixed that by
>>forcing the value of this vector to 0 1 0 in the supervisor program.
>>That should correct the problem. Here is a fixed version of
>>judo_reset_supervisor (source code: judo_reset_supervisor.c, Linux
>>binary: judo_reset_supervisor.gz and Windows binary:
>>judo_reset_supervisor.zip). Mike, please let me know if that fixes the
>>problem.
>>
>>-Olivier
>>
>>Mike Jost wrote:
>>    
>>
>>>Olivier,
>>>
>>>The reset angle for Judoka1 rotates the robot around the X axis instead
>>>      
>>>
>of
>  
>
>>>the Y axis.  The reset angle for Judoda0 is correct.
>>>
>>>Passing the reset string "stand me up 1  0.0  -0.5  1.57" for Judoka1
>>>      
>>>
>gives
>  
>
>>>the attached screen capture Judoka1_Angle_1.57.jpg.
>>>Passing the reset string "stand me up 1  0.0  -0.5  3.14" for Judoka1
>>>      
>>>
>gives
>  
>
>>>the attached screen capture Judoka1_Angle_3.14.jpg.
>>>
>>>Thanks,
>>>Mike Jost (FreeTime)
>>>      
>>>


------------------------ Yahoo! Groups Sponsor ---------------------~-->
Buy Ink Cartridges or Refill Kits for your HP, Epson, Canon or Lexmark
Printer at MyInks.com. Free s/h on orders $50 or more to the US & Canada.
http://www.c1tracking.com/l.asp?cid=5511
http://us.click.yahoo.com/mOAaAA/3exGAA/qnsNAA/pU_rlB/TM
---------------------------------------------------------------------~->

 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
     http://groups.yahoo.com/group/webots-contest/

<*> To unsubscribe from this group, send an email to:
     [email protected]

<*> Your use of Yahoo! Groups is subject to:
     http://docs.yahoo.com/info/terms/
judo_reset_supervisor.c (text/x-csrc, 4.7 KB)
/*****************************************************************************/
/* File:         judo_reset_supervisor.c                                     */
/* Version:      1.0                                                         */
/* Date:         10-Oct-03                                                   */
/* Description:  Supervisor for the Robot Judo Contest                       */
/* Author:       [email protected]                              */
/*                                                                           */
/* Copyright (c) 2003 Cyberbotics - www.cyberbotics.com                      */
/*****************************************************************************/

#include <device/robot.h>
#include <device/supervisor.h>
#include <device/receiver.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define ROBOTS 2  /* number of robots */
#define SERVOS 22 /* number of servos in each robot */

static int verbose=1;
static NodeRef robot[ROBOTS];
static NodeRef servo[ROBOTS][SERVOS];
static float   robot_initial_position[ROBOTS][7];
static float   servo_initial_position[ROBOTS][SERVOS][7];
static float   robot_current_position[ROBOTS][7];
static float   servo_current_position[ROBOTS][SERVOS][7];
static char   *servo_name[SERVOS]={
  "back_1","back_2","left_hip_1","left_hip_2","left_hip_3","left_knee",
  "left_ankle_1","left_ankle_2","left_shoulder_1","left_shoulder_2",
  "left_elbow","neck","neck_tilt","right_hip_1","right_hip_2","right_hip_3",
  "right_knee","right_ankle_1","right_ankle_2","right_shoulder_1",
  "right_shoulder_2","right_elbow"};
static DeviceTag receiver;

void reset() {
  receiver=robot_get_device("receiver");
}

int main() {
  int k,l,m;
  char name[32];
  const char *text;
  float x,z,alpha;

  robot_live(reset);
  receiver_enable(receiver,64);
  for(k=0;k<ROBOTS;k++) {
    sprintf(name,"JUDOKA_%d",k);
    robot[k] = supervisor_node_get_from_def(name);
    supervisor_field_get(robot[k],
			 SUPERVISOR_FIELD_TRANSLATION_AND_ROTATION,
			 (void *)robot_current_position[k],128);
    for(l=0;l<SERVOS;l++) {
      sprintf(name,"%s_%d",servo_name[l],k);
      servo[k][l]=supervisor_node_get_from_def(name);
      supervisor_field_get(servo[k][l],
			   SUPERVISOR_FIELD_TRANSLATION_AND_ROTATION,
			   (void *)servo_current_position[k][l],128);
    }
  }
  robot_step(128); /* get and save initial positions of robots and servos */
  for(k=0;k<ROBOTS;k++) {
    if (verbose>1) printf("SUPERVISOR robot %d: T:%g,%g,%g R:%g,%g,%g,%g\n",k,
			  robot_current_position[k][0],
			  robot_current_position[k][1],
			  robot_current_position[k][2],
			  robot_current_position[k][3],
			  robot_current_position[k][4],
			  robot_current_position[k][5],
			  robot_current_position[k][6]);
    for(m=0;m<7;m++)
     robot_initial_position[k][m]=robot_current_position[k][m];
    // we have to correct the rotation angle which may have changed due
    // to physics simulation before the supervisor process starts
    // (bug reported by Mike Jost)
    robot_initial_position[k][3]=0;
    robot_initial_position[k][4]=1;
    robot_initial_position[k][5]=0;
    for(l=0;l<SERVOS;l++) {
      if (!supervisor_node_was_found(servo[k][l]))
       fprintf(stderr,"SUPERVISOR: servo %s_%d not found\n",servo_name[l],k);
      if (verbose>1) printf("SUPERVISOR  servo %s: T:%g,%g,%g R:%g,%g,%g,%g\n",
			    servo_name[l],
			    servo_current_position[k][l][0],
			    servo_current_position[k][l][1],
			    servo_current_position[k][l][2],
			    servo_current_position[k][l][3],
			    servo_current_position[k][l][4],
			    servo_current_position[k][l][5],
			    servo_current_position[k][l][6]);
      for(m=0;m<7;m++)
       servo_initial_position[k][l][m]=servo_current_position[k][l][m];
    }
  }
  for(;;) { /* never ending loop */
    l = receiver_get_buffer_size(receiver);
    if (l) {
      text = receiver_get_buffer(receiver);
      if (strncmp(text,"stand me up ",12)==0) {
	if (sscanf(text,"stand me up %d %f %f %f",&k,&x,&z,&alpha)==4) {
	  robot_initial_position[k][0]=x;
	  robot_initial_position[k][2]=z;
	  robot_initial_position[k][6]=alpha;
	}
	printf("setting robot %d to position %g %g %g - %g %g %g %g\n",
	       k,
	       robot_initial_position[k][0],
	       robot_initial_position[k][1],
	       robot_initial_position[k][2],
 	       robot_initial_position[k][3],
	       robot_initial_position[k][4],
	       robot_initial_position[k][5],
	       robot_initial_position[k][6]);
	supervisor_field_set(robot[k],
			     SUPERVISOR_FIELD_TRANSLATION_AND_ROTATION,
			     robot_initial_position[k]);
	for(l=0;l<SERVOS;l++)
	  supervisor_field_set(servo[k][l],
			       SUPERVISOR_FIELD_TRANSLATION_AND_ROTATION,
			       servo_initial_position[k][l]);
      }
    }
    robot_step(64);
  }
  return 0;
}
judo_reset_supervisor.gz (application/x-tar, 6.8 KB) - not displayed
judo_reset_supervisor.zip (application/zip, 6 KB) - not displayed