2 questions about direction

Hello Karan, John, other forum users:

I had two questions:

  1. Is it possible to create an encoder setting worksheet with predictable angle-of-turn equivalencies to encoder-targets, such as
  • enc_tgt(1,1,22)= 45 degrees left
  • enc_tgt(0,1,22) = 45 degrees right

If so, we could challenge kids to try to tweak encoder settings in their programs to get their bots to the end of a maze with predictable angles (e.g., 2 left turns of 45 degrees, and 1 right turn of 90 degrees).

  1. For an advanced project where the 2D LIDAR function is used in an unpredictable Maze, and the GoPiGo then moves toward the open spaces… how would the Robot know to turn toward and face one of the open spaces once scanned? You would almost need one anchoring point of orientation in the room (attach a Grove GPS sensor or compass?)

Hey,
It is possible to use predictable angle of turns to make the GoPiGo turn but it would be a bit different for each GoPiGo. It might be a good task for the kids to try out and figure out themself.

We had tried a LIDAR like example with the GoPiGo, the ultrasonic sensor and the Servo and it indeed worked well. You should have a look at the example here: https://github.com/DexterInd/GoPiGo/tree/master/Software/Python/Examples/Ultrasonic_Servo and maybe build up on that.

-Karan

Hey Karan,

Sorry, I did not mention that I knew about the example, and I ran it successfully, and I want to build upon it.

Specifically, how to get the GoPiGo to move toward the open spaces. The example only prints out a map. How would the Robot know to turn toward and face one of the open spaces once scanned? You would almost need one anchoring point of orientation in the room (attach a Grove GPS sensor or compass?)

Thanks!

Ian

Hey Ian,

A possible solution might be to do the following:
Stop
Rotate the servo to create a map.
Rotate towards the relative gap.

The trick is calibrating the wheels in the last step. You should have a precise idea of the relative angle you are from the gap (IE what degree the gap sits from the GoPiGo) and you can turn towards the gap, it might take calibration (a little bit of trial and error) to get the setup just right.

Does that help?

Best,

John

Sure, but what would be the function or mechanism that would automatically measure that angle? Another sensor? Like a compass sensor?

I inferred from your reply that there’s a way to do it without an additional sensor?

Hey Ian,
A simple method to do that might be to find out how much encoder targeting does it take to turn the bot by 15 degrees in both right and left. When you get the map from the ultrasonic sensor, turn a bit towards a direction of the gap and map again. When the gap is in the front, then start moving forward.

Using a compass might be much more easier and we have tried something similar with a compass.

-Karan

Seriously though, how would you program the GoPiGo to autonomously “Move forward if there is a gap in front” and “if no gap in front, turn 15 degrees”?

You can use the encoder targeting with the targets for both the wheels enabled to move the GoPiGo some distance forward. To turn left, you’ll have to experiment a bit with the encoder targeting enabled only for one of the wheel and then you give it left command. That should make it turn just a bit and then encoder targeting kicks in to stop the GoPiGo.

There is not a very good way to do this other than to manually experiment and find out the value of encoder targeting that would work for you. If you want something that is more universal, then you should add a compass module to the GoPiGo.

-Karan