0

Line Robot - MRMS_ESP32.ino sketch

Zašto ovako?

Any normal Arduino course starts with something very alike hello-world-program in which a program prints "Hello world" or does a similar, simple task. While it is possible for us to go the same way, the process would be very long before we get any useful robot actions. There is different approach, not to use Arduino development environment, but to write a program that accepts only a limited user scripts, like Lego or Fischertechnik. We decided to use a third way, to give You total control and get the results fast. The downside will be that You will immediately start working in a complex, object-oriented, Arduino program. Follow the instructions and nothing bad will happen. Later, we will explain the details of this monster. Just imagine that we started with CAN Bus messaging to sensors and motors... You would be dead-bored before the robot started doing anything.

On the other hand, be ready for a steep learning curve. You will have to grasp rather advanced concepts right in the beginning. That will make sure that You will have much less problems later. The right concept will reveal itself later, cutting development time of any advanced robot manyfold.

If You are more oriented towards smaller code samples, related to specific hardware options, and concept presented here doesn't seem right for You, use this page to see other approach to the problem.

Install MRMS_ESP32.ino.

If not already, install MRMS_ESP32.ino.

Checking hardware

You can connect now all the CAN Bus devices. Start from MRMS ESP32: Arduino, IMU, eFuse, BT, WiFi, CAN Bus (mrm-esp32) and continue chaining any way You like. Each CAN Bus node should have unique address. If Your sensors are not prepared yet, use this page to see the procedure.

Start MRM_ESP32.ino and open Arduino monitor. Program displays all the predefined commands. You can use them to check Your sensors and motors. Type "can" again in the input box above the displayed text and hit "Send" button:

The result will be a list of all the CAN Bus devices in Your robot. If some are missing, they probably incorrectly wired. If any of them use ancient firmware, it there is a change for address collision. In that case update the firmware to the new (plug and play) or manually change the addresses until each device gets a unique one.

Enter command "li2" and watch lidars displaying distances in mm:

. There must be 3 columns, for 3 lidars, and they have to be all changing values. Stop display by entering command "x".

Test the motors using command "mot":

. Each motor should be rotating in one direction briefly and the in another. To test reflective sensors, first enter "ref" command to enter submenu for reflective sensors. This step is optional as the can enter the next command, "anr", in the main menu, too, but this way You can see all the available commands. So, type now "anr":
. You will get 9 columns, for 9 transistors that form MRMS reflectance sensors 9x, CAN, analog, I2C (mrm-ref-can). Even if You use some other sensor, like MRMS reflectance sensors 8x, CAN, analog, I2C (mrm-ref-can8) (8 transistors), You will get again 9 columns. However, only the columns that have corresponding transistors will be changing.