wheel odometry is zeroed out whenever I access the bumper sensor on the Original irobot create

17 views
Skip to first unread message

cmi...@gmail.com

unread,
Jul 15, 2016, 7:06:32 AM7/15/16
to iRobot Create Forum


This is how I access the bump sensors: I use lib biscuit.

i

   
}
#define BISC_SENSOR                           142
#define BISC_SENSOR_BUMPS_AND_WHEEL_DROPS     7
#define BISC_SUCCESS  0
#define BISC_ERR     -1

int biscSendByte(unsigned char byte) {
    usleep
(10000);
   
return (write(deviceDescriptor, &byte, 1) == 1 ? BISC_SUCCESS : BISC_ERR);
}
 
int biscReceiveByte(unsigned char  &byte) {
    usleep
(10000);
   
return (read(deviceDescriptor, &byte, 1) == 1 ? BISC_SUCCESS : BISC_ERR);
}

int biscBumps(unsigned char & bumpbyte) {
   
if(biscSendByte(BISC_SENSOR) == BISC_ERR) return BISC_ERR;
   
//cout << "Sent Sensor" << endl;
   
if(biscSendByte(BISC_SENSOR_BUMPS_AND_WHEEL_DROPS) == BISC_ERR) return BISC_ERR;
   
// cout << "Sent Bump " << endl;
   
//usleep(2000000);
   
if(biscReceiveByte(bumpbyte)  == BISC_ERR) return BISC_ERR;
   
// cout << "Received Byte " << endl;
   
return BISC_SUCCESS;
}

I am getting the correct bump sensor reading  by checking state of right most bits ( 1 and 2 ) of bumpbyte.  I am doing it in a loop while the create is moving so it will stop when an obstacle is hit.  I zero the odometry reading by retrieving the distance and angle measurements prior to making the robot move.  After the move, I request the distance and angle measurements again.  I get zero reading from the odometer if I activate the bump sensor in the loop. It's like I can only use one or the other but not both. Is this normal?



 

Joe Lucia

unread,
Jul 15, 2016, 9:16:14 AM7/15/16
to irobot-cr...@googlegroups.com
Try reading sensor packet 0 where you get all data back at once then extract the values you need into global variables to use anywhere else at any time in the app.  The odometer data gets reset every time you request it from the robot so you need to accumulate each reading to get a running total.  I'm not sure if reading the bumper data individually is resetting the odometer reading though (it shouldn't), but I've always read full sensor packets as opposed to reading one sensor at a time.

Ideally you should be reading the sensor data in a separate thread (or interrupt driven receive routine) so it happens continuously in the background while your app loops and references the the global variables without needing to poll and wait for the data.



Joe Lucia, CTO

AZSecurity Control
 | www.AzSecurity.com
1042 E Guadalupe Rd, Tempe, AZ 85283
Phone 480-752-7115 | Fax 480-829-9290
Email J...@AzSecurity.com

--
You received this message because you are subscribed to the Google Groups "iRobot Create Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to irobot-create-f...@googlegroups.com.
To post to this group, send email to irobot-cr...@googlegroups.com.
Visit this group at https://groups.google.com/group/irobot-create-forum.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages