Asked

Some More Encoder

DJ hi,  I am getting some weird map results in Better Navigator using the encoder counter skill. Using a Roomba via PC COM port and for Level #3 Group #2, I taped into Roomba encoders that go to an Arduino with Wheel Encoder UNO firmware. For Level #3 Group #1, I use a RPLidar. In the config of the Wheel Encoder Counter skill, I enable the push to NMS checkbox and leave all other settings default as they exactly match the Roomba. In The Better Navigator, I use External as pose hint source. What I am experiencing is that when I move forward or backward, the map creation seems ok, but as soon as I turn left or right, the map gets all messed up. The counts from the encoders are surprisingly good. My guess is that the BN is not processing encoder counts correctly with the left and right commands?


Related Hardware Roomba
Related Control The Better Navigator

ARC Pro

Upgrade to ARC Pro

Stay on the cutting edge of robotics with ARC Pro, guaranteeing that your robot is always ahead of the game.

PRO
Synthiam
#9  

The firmware wont' know the wheel direction - so that's gonna be a challenge if you're trying to do it in the EZB firmware. The robot skill is where it needs to be. Either that - or the robot skill can send a command to the firmware that explains the current direction. Actually, i like that.

I think the robot skill and firmware should be modified to accept a command that defines the wheel directions. That way, the firmware knows to add or subtract the encoder value. Everytime the Movement Panel direction changes, it sends an update to the firmware. The firmware will then use that value to determine how to alter the encoder count.

What do you think?

Btw the wheel encoder robot skill firmware is here if you wanna see how it's working: https://github.com/synthiam/Robot-Skill-Wheel_Encoder_Counter

PRO
Portugal
#10   — Edited

Thank you @Athena and DJ,

The count pulses from the roomba encoder are suprisingly acurate. Just forget that the encoder is from the roomba and assume its a regular pulse count encoder. Would the Movement Panel from roomba send the direction to NMS or The Better Navigator?

I also think its a good idea to send direction to the arduino.

PRO
Canada
#11  

It's great to hear that the encoder pulses are accurate! Given that, let's focus on how to integrate the direction information effectively.

Movement Panel and Direction Communication

  1. Movement Panel to NMS/Better Navigator:

    • The Movement Panel in ARC is responsible for controlling the robot's movement. It can send direction commands to the Navigation Messaging System (NMS) or the Better Navigator. This ensures that the navigation system is aware of the robot's intended movement direction.
  2. Sending Direction to Arduino:

    • As DJ suggested, modifying the robot skill to send direction commands to the Arduino is a practical approach. This way, the Arduino can adjust the encoder counts based on the current movement direction.

Implementation Steps

  1. Modify the Robot Skill:

    • Update the robot skill to send direction commands to the Arduino whenever the movement direction changes. This can be done using a custom command that the Arduino firmware will recognize.
  2. Update Arduino Firmware:

    • Modify the Arduino firmware to accept direction commands. Use these commands to determine whether to increment or decrement the encoder counts.
  3. Direction Command Protocol:

    • Define a simple protocol for direction commands. For example, you could use specific byte values to represent each direction (e.g., 0x01 for forward, 0x02 for backward, etc.).
  4. Testing:

    • Test the system to ensure that the encoder counts are adjusted correctly based on the movement direction. Verify that the navigation system receives accurate pose information.

Example Code Snippet

Here's a basic example of how you might implement the direction command handling in the Arduino firmware:

enum Direction { FORWARD, BACKWARD, LEFT, RIGHT, STOP };
Direction currentDirection = STOP;

void handleDirectionCommand(byte directionCmd) {
    switch (directionCmd) {
        case 0x01:
            currentDirection = FORWARD;
            break;
        case 0x02:
            currentDirection = BACKWARD;
            break;
        case 0x03:
            currentDirection = LEFT;
            break;
        case 0x04:
            currentDirection = RIGHT;
            break;
        default:
            currentDirection = STOP;
            break;
    }
}

void countLeft() {
    if (currentDirection == FORWARD || currentDirection == RIGHT) {
        _WheelLeftCnt++;
    } else if (currentDirection == BACKWARD || currentDirection == LEFT) {
        _WheelLeftCnt--;
    }
}

void countRight() {
    if (currentDirection == FORWARD || currentDirection == LEFT) {
        _WheelRightCnt++;
    } else if (currentDirection == BACKWARD || currentDirection == RIGHT) {
        _WheelRightCnt--;
    }
}

Conclusion

By implementing these changes, you can ensure that the encoder counts accurately reflect the robot's movement direction, improving the navigation system's performance. If you have any further questions or need additional assistance, feel free to ask!


I am a customer support GPT-powered AI and still learning. If you have doubts about my response, please use the support documentation to verify my answer.
PRO
Synthiam
#12  

Okay i modified the firmware and robot skill of the Wheel Encoder to add or subtract the values based on the Movement Panel direction. Check the updated v10 wheel encoder robot skill and the new firmware for it.

Quote:

The count pulses from the roomba encoder are suprisingly acurate. Just forget that the encoder is from the roomba and assume its a regular pulse count encoder. Would the Movement Panel from roomba send the direction to NMS or The Better Navigator?

I was under the impression, based on your previous message, that you are using the roomba to send it's pose data to the NMS from an Arduino UNO with the wheel encoders. Based on this question, I'm not sure I fully understand now what you're doing now:D.

  1. The roomba has built-in encoders and the roomba Movement Panel can send it's pose data to the NMS without you needing an arduino or anything else. It does it on its own

  2. If you're not using the roomba's built-in encoder value counter and using an arduino wheel encoder, then you'd have to continue on with what i posted above.

I would use #1 because it doesn't require any additional hardware. The Roomba Movement Panel (https://synthiam.com/Support/Skills/Movement-Panels/iRobot-Roomba-Movement-Panel?id=19164) manual explains more.

PRO
Portugal
#13  

LOL DJ, what a mess. I apologise for my poor fraise construction as it is not my native language. I am indeed using the Roombas encoders hoked up to an Arduino. I read in some posts that the data coming from the Roomba directly would go back to "0" when reaching 65565 or so. Will test the new firm and skill. Thank you.

PRO
Synthiam
#14  

Haha okay - no prob. We're progressing:)

I don't recall about the roomba robot skill going back to 0 but that could be the case. I'm sure it's something that can be fixed. Have you experienced issues by trying it? My first recommendation would be not use the roomba robot skill and see if you like that.

However, if you want to test out the new code i created - let me know. It "should" work based on my conceptual plan but it isn't tested. I'm just sitting watching the waves roll in while it rains outside. So i figured i should write some code and get you rock'n.:)

PRO
Portugal
#15  

Bad news DJ, now as soon as I go forward both encoder counts jump from 0 to 6547.

User-inserted image

Ah and here is the thred I was talking about the roomba encoders.

User-inserted image

PRO
Synthiam
#16  

Ah okay - sounds like my logic is reversed in the firmware. You can edit and swap the ++ and - for the encoder count increments to try it.

im not at home anymore so I can’t make the changes rn