From https://www.jetbrains.com/pycharm/
I am using Pycharm to develop the python program as well as the Arduino program.
To associate C/C++ syntax highlighting with .ino
files, follow Sawyer McLane's tutoral.
Clone the project from the github repository. To do it from within Pycharm, see Pycharm documentation.
After cloning the project, PyCharm may automatically propose you to install the required packages. Or you can execute this command in the project directory:
pip install -r requirements.txt
If you are editing your Arduino project in another IDE like Pycharm, then check "Use an external editor" in the Arduino IDE preferences.
This project uses the following libraries:
Library | Function | Where to find it |
---|---|---|
Servo | Servo motor | Installed by default with the Arduino IDE |
HC-SR04 | Ultrasonic telemeter | Regular Osoyoo robot |
WifiEsp-master | Wifi Shield | Regular Osoyoo robot (Lesson 5 : WiFiEsp-master.zip) |
Arduino_JSON | JSON | Arduino IDE Library manager |
MPU6050 | Inertial Measurement Unit | Included in our project repository |
HLC5883L | Compass | Included in our project repository |
MMC5883 | Compass | Included in our project repository |
Adafruit_TCS34725 | Color sensor | Arduino IDE Library manager |
Follow the Osoyoo introduction lessons to install the libraries needed by the regular Osoyoo Robot:
I adapted the MPU6050 library by Korneliusz Jarzebski and included it in this project.
I had to add a timeout to avoid freezing the main loop if the MPU6050 is not responding. This seems to happen because of the noise caused by the motors.
In file MPU6050.cpp
, I added this line after Wire.begin() in line 38 (documentation here):
Wire.setWireTimeout( 25000, true);
Also, I had to edit the MPU6050.cpp
to prevent it from aborting the initialization process when the address is not 0x68:
Figure 2: Comment the return false; in line 56
After looking at a few alternatives, I chose this library because it was also provided with my Arduino kit by Elegoo. It is provided in the arduino-kits-support-files. The file Mega_2560_The_Most_Complete_Starter_Kit contains the whole pedagogical material, including the electronic wiring diagram.
Install Arduino_JSON by Arduino from the library manager:
Don't mistake it with the library ArduinoJSON
by Benoit Blanchon.
This library handles the compass chip HMC5883L implemented in some of the GY-86 imu cards, This project includes a version adapted from Jarzebski's library.
Figure 3: The IMU card with the compass chip labeled L883/2131
.
If your compass chip begins with L883
, include the following lines in robot_define.h
for your robot:
#define ROBOT_HAS_MPU6050 true
#define ROBOT_COMPASS_TYPE 1
This library handles the compass chip Duinotech MMC5883L implemented in some imu cards. I followed the article by David Such that lists the different compass chips. I adapted this library from his repo.
Figure 4: The IMU card with the compass chip labeled 5883/601X
.
If your compass chip begins with 5883
, include the following lines in robot_define.h
for your robot:
#define ROBOT_HAS_MPU6050 true
#define ROBOT_COMPASS_TYPE 2
In the autocat_enacter\src\wifi
folder, next to the WifiCat.cpp
and WifiCat.h
files, create the file arduino_secrets.h
.
This file is registered in .gitignore so it won't be pushed to GitHub. Your wifi password won't be shared to the world.
To let the robot connect to your own wifi as a station (STA), arduino_secrets.h
must contain:
#define SECRET_WIFI_TYPE "STA"
#define SECRET_SSID "<your wifi SSID>"
#define SECRET_PASS "<your password>"
Alternatively, to let the robot provide its own wifi petitcat
as an access point (AP), arduino_secrets.h
must contain:
#define SECRET_WIFI_TYPE "AP"
The robot's IP address will show in the serial terminal: