Author Topic: iRobot Create 156 and 157 command  (Read 5136 times)

0 Members and 1 Guest are viewing this topic.

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
iRobot Create 156 and 157 command
« on: August 04, 2007, 11:10:37 AM »
Anyone have source code using either the 156 or 157 command for the Create?

The source code that iRobot offers doesnt use those commands to operate the encoders.

Instead it cheats with occasionally reading the encoders, but doesnt check if it drifts over . . . resulting in huge errors . . . I wrote a subroutine that keeps track of the error to account for it in the next motion, but it doesnt correct for it. Better, but still bad drift . . .

The closest I can find is the source code for 137 (which I got to work):

// Send Create drive commands in terms of velocity and radius
void drive(int16_t velocity, int16_t radius)
{
  byteTx(137);
  byteTx((uint8_t)((velocity >> 8) & 0x00FF));
  byteTx((uint8_t)(velocity & 0x00FF));
  byteTx((uint8_t)((radius >> 8) & 0x00FF));
  byteTx((uint8_t)(radius & 0x00FF));
}

But Im clueless to why that works . . .

I'd ask in the iRobot forum, but the registration part of the site is broken . . . Im sooo not impressed by this robot so far . . .

Offline AdminTopic starter

  • Administrator
  • Supreme Robot
  • *****
  • Posts: 11,703
  • Helpful? 173
    • Society of Robots
Re: iRobot Create 156 and 157 command
« Reply #1 on: August 04, 2007, 01:54:41 PM »
Ok I got the below code to work, sorta. I posted it for whomever might need it in the future.

But its still insanely inaccurate :-[

I figured maybe the encoder sucks . . . so I opened it up and found a very high resolution encoder driven by a rubber belt . . . perhaps the rubber stretching is throwing off the encoders? Anyone know what the resolution is? The manuals (all four of them) only mention that there is an encoder involved and nothing more . . .

Code: [Select]
void drive_distance(int16_t velocity, int16_t radius, int16_t distance_togo)
{
  byteTx(CmdDrive);
  byteTx((uint8_t)((velocity >> 8) & 0x00FF));
  byteTx((uint8_t)(velocity & 0x00FF));
  byteTx((uint8_t)((radius >> 8) & 0x00FF));
  byteTx((uint8_t)(radius & 0x00FF));
  byteTx(156);
  byteTx((uint8_t)((distance_togo >> 8) & 0x00FF));
  byteTx((uint8_t)(distance_togo & 0x00FF));
}

void drive_angle(int16_t velocity, int16_t radius, int16_t angle_togo)
{
  byteTx(CmdDrive);
  byteTx((uint8_t)((velocity >> 8) & 0x00FF));
  byteTx((uint8_t)(velocity & 0x00FF));
  byteTx((uint8_t)((radius >> 8) & 0x00FF));
  byteTx((uint8_t)(radius & 0x00FF));
  byteTx(157);
  byteTx((uint8_t)((angle_togo >> 8) & 0x00FF));
  byteTx((uint8_t)(angle_togo & 0x00FF));
}

 


Get Your Ad Here

data_list