[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Libirobot-create-users] Problem with odometry

From: Thomas Moulard
Subject: [Libirobot-create-users] Problem with odometry
Date: Sat, 30 Aug 2008 04:30:16 -0700

Hash: SHA1

On Fri, Aug 29, 2008 at 11:22 PM, Christian Siagian  wrote:
> Dear Thomas,
> I have a problem with the iRobot-create. I still can't get the odometry data.
> I query the sensor using both the
> sendSensorCommands(CREATE::SENSOR_DISTANCE)
> and
>      Create::sensorPackets_t qSensors;
>      qSensors.push_back(Create::SENSOR_DISTANCE);
>      qSensors.push_back(Create::SENSOR_ANGLE);
>      robot.sendQueryListCommand(qSensors);
> and both return garbage valueof either  4870 and 1543
> I think I have to check from scratch just to see if the encoder is busted or 
> not or if you parsed the code incorrectly.
> Where do you think I should go about starting doing this.

You might want to check-out the documentation, especially how to get the
code from the git repository (

When you'll have got the last development version, do:
mkdir _build && cd _build

Then, in _build directory, put your test code:

and compile with the local library:
g++ -I../src -Lsrc/.libs --Wl,-Rsrc/.libs -lirobot-create -o test
and run:

To check if the generated bytes are right or wrong, do the following thing:
Use a stringstream to create the robot object:

int main () {
std::stringstream ss;
iRobot::Create robot (ss);
// get the odometry data.
std::cout  2 packets (19 and 20)

If the generated bytes are right => check the sensor reading
If the bytes are wrong, the problem is in this file:;a=blob;f=src/;h=bded132a732dc67ce893fa53af2091e283968137;hb=273a0a6fa13b0f14b25c11b055d8c1e05918bfb2

Check Create::sendQueryListCommand (const sensorPackets_t& packets) (line 555),
it is where the error should be.

However, it is extremely unlikely that the bug is here as the code is
really easy.

The complex code is the reading part from line 693 to 952.

Here is how it is working:
when you want to get the value of one sensor, updateSensors [line 694]
is called to check if a new value has been
If we see a stream header, then we parse the full stream (it is
special because you have to parse the checksum).

For "normal" polling, I maintain a queue called queriedSensors_ which
contains the type of packets I expect
to receive.
readSensorPacket () [line 717] => read the next expected sensor packet

Then it calls:
Create::readSensorPacket (SensorPacket sensor, std::istream& stream) [line 767]
to be able to parse a specific packet.

To finish, I have the "big switch case" that apply a specific treatment to each
kind of packet.

The packets that interest you are line 845 and 846.
It uses the macro defined line 746. Basically it just calls receivedInt.

To debug that part, just try to see if the right functions are called and
where the wrong value comes from.
There is no special mechanism to see what is received yet except
adding debug code manually.

If you can send me a patch, I'll apply it however as iRobot does not
sell iRobot Create in Europe I won't be able to get it one soon :\.

I hope you'll figure out the problem easily,
- --
Thomas Moulard

Version: GnuPG v2.0.9 (GNU/Linux)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]