To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.robotics.rcxOpen lugnet.robotics.rcx in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / RCX / 664
663  |  665
Subject: 
Re: Troubleshooting RCX Problems
Newsgroups: 
lugnet.robotics.rcx
Date: 
Sun, 6 Aug 2000 14:11:46 GMT
Viewed: 
1685 times
  
"Mario Ferrari" <mario.ferrari@edis.it> wrote in message
news:FyvIAK.8or@lugnet.com...
Hi Tim,
would you post here your code so we can have a look at it?

Mario

Here you go:
--

Tim Courtney - tim@zacktron.com

http://www.ldraw.org - Centralized LDraw Resources
http://www.zacktron.com - Zacktron Alliance

ICQ: 23951114
AIM: TimCourtne
--

//--------------------------------------------------------------------------
--
// MIBO ƒRƒ“ƒgƒ[ƒ‹ƒvƒƒOƒ‰ƒ€  MIBO-R01.nqc
// Œã‚ë‘«’S“–
// NQC Ver2.2 ‚ŃRƒ“ƒpƒCƒ‹‚·‚邱‚Æ
//
// Create by Jin Sato   http://www.mi-ra-i.com/JinSato/
//
// M = MindStorms
// I = Integrade
// B = Bionic
// O = Object
//
//--------------------------------------------------------------------------
--
// 1999/06/23 | Œã‚ë‘«‚ðŒ³‚É‘O‘«‚̃vƒƒOƒ‰ƒ€‚ðì‚éB
// 1999/08/12 | ‚¨À‚è‚̃vƒƒOƒ‰ƒ€
// 2000/02/12 | ŒöŠJ—p‚ɏC³
//
//--------------------------------------------------------------------------
--



//--------------------------------------------------------------------------
--
// ƒOƒ[ƒoƒ‹•Ï”’è‹`B  (RCX‚ł̓Oƒ[ƒoƒ‹•Ï”‚µ‚©Žg‚¦‚È‚¢j

int fgWalk;
int fgTail;
int fgSit;


//--------------------------------------------------------------------------
--
// Œã‚ë‘«‚Ì‘æ“ñŠÖß‚ð‰Šú‚̈ʒu‚É–ß‚·
//
void SetBeginPotition()
{
int  nTemp;
fgWalk = 3;

SetPower( OUT_A + OUT_B + OUT_C, 7 );


while ( fgWalk != 0 ) {
  nTemp = SENSOR_3;
  if ( nTemp <= 1 && nTemp >= -1 ) { // ­‚µ”
͈͂ðL‚°‚Ä‚¨‚©‚È‚¢‚ÆŽ~‚Ü‚ç‚È‚¢ê‡‚ª‚ ‚é
   fgWalk &= ~0x02;
   Off( OUT_C );
  }  else {
   if ( nTemp  > 0 ) {
    OnFwd( OUT_C );
   } else {
    OnRev( OUT_C );
   }
  }
  nTemp = SENSOR_1;
  if ( nTemp <= 1 && nTemp >= -1 ) {
   fgWalk &= ~0x01;
   Off( OUT_A );
  } else {
   if ( nTemp  > 0 ) {
    OnRev( OUT_A );
   } else {
    OnFwd( OUT_A );
   }
  }
}
}

//--------------------------------------------------------------------------
--
// •à‚¢‚Ä‚¢‚é‚Ì‚ðŽ~‚ß‚éB
//
void StopWalk()
{
if ( fgWalk != 0 ) {
  stop HizaMonitor;
  stop Walk;
  stop Tail;

  Off( OUT_B );
  SetBeginPotition();
}
}


//--------------------------------------------------------------------------
--
// •G‚Ì•”•ª‚ª‹K’èˆÈã‚ɉñ“]‚µ‚½ê‡AƒXƒgƒbƒv‚·‚éB
//
#define  KICK_ANGLE  200

task HizaMonitor()
{
while ( true ) {
  if ( SENSOR_3  > KICK_ANGLE ) {
   Off( OUT_C );
  }
  if ( SENSOR_3  < -KICK_ANGLE ) {
   Off( OUT_C );
  }

  if ( SENSOR_1  < -KICK_ANGLE ) {
   Off( OUT_A );
  }
  if ( SENSOR_1  > KICK_ANGLE ) {
   Off( OUT_A );
  }
}
}

//--------------------------------------------------------------------------
--
// —”‚ðŒ³‚ÉK”ö‚ðU‚é
//
task Tail()
{
while ( true ) {
  fgTail = Random( 3 );

  if ( fgTail == 1 ) {
   wanwan();
   SetPower( OUT_B, 1 );
   OnFwd( OUT_B );
   Wait( 14 );
   OnRev( OUT_B );
   Wait( 14 );
  }
  Off( OUT_B );

  fgTail = Random( 100 ); // + 30;

  Wait( fgTail );
}
}

//--------------------------------------------------------------------------
--
// ¶‰E‚ÌŒã‚ë‘«‚Ì‘æ“ñŠÖßi•Gj‚ð‘OŒã‚É“®‚©‚µ‚·B
//
//
task Walk()
{
SetPower( OUT_A + OUT_B + OUT_C, 7 );

if (  fgWalk == 0 ) { // ‚Ü‚¾•à‚¢‚Ä‚¢‚È‚¢Žž‚É‚Í•à‚­B
  //
  // ƒOƒ[ƒoƒ‹‚̃tƒ‰ƒO‚ðOn‚É‚µ‚Ä‚¨‚­
  fgWalk = 1;


  // ‰E‚ÌŒã‚ë‘«‚©‚炯‚èŽn‚ß‚éAMIBO‚Ì‚«‚«‘«‚͉E‚¾(^^)
  do {
   OnRev( OUT_C );
  } while ( SENSOR_3  < KICK_ANGLE );

  while ( true ) {

   if ( fgWalk < 7 ) {
    //‰E‘«‚ðŒ³‚ÌˆÊ’u‚É–ß‚·
    if ( SENSOR_3  > 0 ) {
     OnFwd( OUT_C );
    } else {
     Off( OUT_C );
     fgWalk |= 0x02;  // ‰‚߈ʒu‚É–ß‚Á‚½‚ç ƒtƒ‰ƒO‚ðƒZƒbƒg
    }

    // ¶‘«‚ð‚¯‚èo‚·B
    if ( SENSOR_1  > -KICK_ANGLE ) {
     OnRev( OUT_A );
    } else {
     Off( OUT_A );  // Š®‘S‚É‚¯‚肪I‚í‚Á‚½‚ç ƒtƒ‰ƒO‚ðƒZƒbƒg
     fgWalk |= 0x04;
    }
   }

   //
   if ( fgWalk == 7 ) {
    if ( SENSOR_3  < KICK_ANGLE ) {
     OnRev( OUT_C );
    } else {
     Off( OUT_C );
     fgWalk &= ~0x02;
    }

    if ( SENSOR_1  < 0 ) {
     OnFwd( OUT_A );
    } else {
     Off( OUT_A );
     fgWalk &= ~0x04;
    }
   }
  }
}
}


//--------------------------------------------------------------------------
--
//  ‚¨À‚è
//
//

#define SIT_ANGLE_1  100   // ‘«‚Ì•t‚¯ª‚Ì‹È‚ª‚éŠp“x‚ðŽw’è
#define SIT_ANGLE_2  350

sub  Sit()
{
if ( fgSit == 0 ) {
  SetPower( OUT_A + OUT_B + OUT_C, 7 );

  // ‰‚߂ɏ­‚µ‹È‚°‚é
  do {
   OnRev( OUT_B );
  } while ( SENSOR_2 < SIT_ANGLE_1 );

  // ‚»‚ÌŒãA•G‚à‹È‚°‚È‚ª‚çÀ‚Á‚Ä‚¢‚­
  do {
   OnRev( OUT_B );
   if ( SENSOR_1 > -390 ) {
    OnRev( OUT_A );
   } else {
    Off( OUT_A );
   }
   if ( SENSOR_3 < 390 ) {
    OnRev( OUT_C );
   } else {
    Off( OUT_C );
   }
  } while ( SENSOR_2 < SIT_ANGLE_2 );
  Off( OUT_B );
}
fgSit = 1;
}

//--------------------------------------------------------------------------
--
//
sub  Up()
{
if ( fgSit != 0 ) { // ‚à‚µ‚àÀ‚Á‚Ä‚¢‚ê‚Î

  SetPower( OUT_A + OUT_B + OUT_C, 7 );

  do {
   OnFwd( OUT_B );
  } while ( SENSOR_2 > 200 );

  do {
   OnFwd( OUT_B );

   if ( SENSOR_1 < 0 ) {
    OnFwd( OUT_A );
   } else {
    Off( OUT_A );
   }
   if ( SENSOR_3 > 0 ) {
    OnFwd( OUT_C );
   } else {
    Off( OUT_C );
   }

  } while ( SENSOR_2 > 0 );
  Off( OUT_B );
}
fgSit = 0;

}
//--------------------------------------------------------------------------
--
// ƒƒ“ƒƒ“‚Æ‚Ù‚¦‚é
void wanwan()
{
PlayTone( 1462,1 ); PlayTone( 2462,1 );
PlayTone( 1462,1 ); PlayTone( 2462,1 );
}

//--------------------------------------------------------------------------
--
//
task main()
{

// ‰¹‚ðo‚·
wanwan();


// ‰E‘«‚̃Aƒ“ƒOƒ‹ƒZƒ“ƒT[
SetSensorType( SENSOR_1, SENSOR_TYPE_ROTATION );
SetSensorMode( SENSOR_1, SENSOR_MODE_ROTATION );
ClearSensor( SENSOR_1 );

// ¶‘«‚̃Aƒ“ƒOƒ‹ƒZƒ“ƒT[
SetSensorType( SENSOR_3, SENSOR_TYPE_ROTATION );
SetSensorMode( SENSOR_3, SENSOR_MODE_ROTATION );
ClearSensor( SENSOR_3 );

// ‘æˆêŠÖß‚̃Aƒ“ƒOƒ‹ƒZƒ“ƒT[
SetSensorType( SENSOR_2, SENSOR_TYPE_ROTATION );
SetSensorMode( SENSOR_2, SENSOR_MODE_ROTATION );
ClearSensor( SENSOR_2 );



//
fgWalk = 0;
fgSit  = 0;



while(true) {
  ClearMessage();
  until( Message() != 0 );

  switch( Message() ){
  case 1:
   if ( fgWalk != 0 ) { // ‚à‚µ¡•à‚¢‚Ä‚¢‚ê‚΁B •à‚­‚Ì‚ðŽ~‚߂ătƒ‰ƒO
    wanwan();

    StopWalk();
    stop HizaMonitor;

    ClearSensor( SENSOR_1 );
    ClearSensor( SENSOR_2 );
    ClearSensor( SENSOR_3 );

    fgWalk = 0;
    wanwan();

   } else {
    //
    wanwan();
    Up();

    PlayTone( 294 * 2,10 );
    PlayTone( 462,10 );

    start HizaMonitor;
    start Walk;
    start Tail;
    wanwan();
   }
   break;


  //  ‚¨‚·‚í‚è
  case 2:
   if ( fgSit != 0 ) {
    wanwan();
    Up();

    ClearSensor( SENSOR_1 );
    ClearSensor( SENSOR_2 );
    ClearSensor( SENSOR_3 );
    wanwan();

   } else {
    wanwan();
    StopWalk();
    Sit();
    wanwan();

   }
   break;
  }
}
}



Message has 2 Replies:
  Re: Troubleshooting RCX Problems
 
(...) Aha, that's famous MIBO code. Unfortunately japanise comments don't help so much :-) Can you tell me which rotation sensor shows the problem, I mean port 1, 2 or 3. Mario (24 years ago, 6-Aug-00, to lugnet.robotics.rcx)
  Re: Troubleshooting RCX Problems
 
On Sun, 6 Aug 2000 14:11:46 GMT, "Tim Courtney" <tim@zacktron.com> wrote: The Japanese comes out all garbled. Could you please translate to enlish? (...) (24 years ago, 6-Aug-00, to lugnet.robotics.rcx)

Message is in Reply To:
  Re: Troubleshooting RCX Problems
 
(...) the (...) Hi Tim, would you post here your code so we can have a look at it? Mario (24 years ago, 6-Aug-00, to lugnet.robotics.rcx)

6 Messages in This Thread:


Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact

This Message and its Replies on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    

Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR