I.Objective
II.Parts and Devices
III.Hardware Installation
IV.Circuit Connection
V.Software Installation
VI.How to play
Mecanum Wheel Robot Car Full Package (with 18650 batteries)
Buy from US | Buy from UK | Buy from DE | Buy from IT | Buy from FR | Buy from ES | ここでご購入を! |
The above robot cars are controlled by Arduino. If you have Raspberry Pi board, actually the robot car can also be controlled by Raspberry Pi. You can visit the following link to learn basic movement with Raspberry Pi.
link- https://osoyoo.com/?p=31428
In this project, we will connect the Mecanum robot car to Wi-Fi and use an APP to control the car through the Internet. This is a typical Internet of Things (IoT) Application.
OSOYOO Mecanum wheels robotic car chassis x 1 (2x left-wheels/2x right-wheels and Motor x 4)
OSOYOO Mega2560 board, fully compatible with Arduino MEGA2560 board x 1
OSOYOO Wi-Fi shield x 1
OSOYOO Model Y motor driver x 1
OSOYOO MG90 servo motor x 1
OSOYOO Ultrasonic sensor module x1
OSOYOO Ultrasonic mount holder
OSOYOO 5-Point Tracking sensor module
OSOYOO 3pin female to female jumper wire x1
OSOYOO 6pin male to female jumper wire x2
OSOYOO 7pin female to female jumper wire x1
OSOYOO 2 pin XH.25 female to female x1
OSOYOO Battery box x 1
18650 Batteries(3.7V) x 2
If you just finish all lesson 1 (assembling the car) and lesson 4 (Bluetooth imitation driver), please keep all lesson connections same as it is. Then plug out Bluetooth from Wi-Fi Shield.
Step 1. Remove the connection B_TX to D18 and B_RX to D19.
Step 2. Connect E_RX to D18(TX1) and E_TX to D19(RX1).
(Note: You need to split 2 pcs of male-to-female jumper wires from our 10-pc jumper wire bundle. Any color from the bundle will be ok. The rest of 8 pcs wires are as spare parts for potential broken or damaged wires.)
Open-source Arduino Software(IDE) |
Download Arduino IDE here: https://www.arduino.cc/en/Main/Software?setlang=en |
|
7 zip is a free zip utility that unzips zip files |
Download 7zip here for free https://www.7-zip.org/ |
Step 1: Install latest Arduino IDE (If you have Arduino IDE version after 1.1.16, please skip this step). Download Arduino IDE from https://www.arduino.cc/en/Main/Software?setlang=en, then install the software.
Step 2: Please download the library zip file from WiFiEsp-master.zip.Open Arduino IDE →click Sketch →Include Library →Add .ZIP library, then load above zip file into Arduino.
Step 3: APP installation-you need to search “OSOYOO Wi-Fi UDP Robot Car Controller” in Google Play or Apple Store, and then install this APP.
YOU CAN ALSO DOWNLOAD APP DIRECTLY FROM https://osoyoo.com/driver/arduino-udp/udp-robot.apk
Step 4:Arduino Sketch code Installation:
Download: https://osoyoo.com/driver/mecanum_metal_chassis_m2/m2-lesson5.zip
Unzip the downloaded file, enter the m2-lesson5 folder, you will see two sub-folder :
m2-lesson5A and m2-lesson5B
These two folders have program for two Wi-Fi modes: AP mode and STA mode. The Arduino sketches for these two modes are different. Let’s explain these two modes one by one
When working in AP mode, our robot car itself will become a Wi-Fi Hot Spot. Our cell phone can connect to Robot Car as its Wi-Fi client. The IP address of Robot is fixed to 192.168.4.1. In such situation, both the robot car and your cell phone are not connected to WAN.
(1) Unzip the m2-lesson5 file, and you will see a folder named m2-lesson5a, upload the code into Arduino.
(2) Open your Arduino Serial monitor, and you will see a similar result as AP mode. A new Wi-Fi SSID “osoyoo_robot” with IP address 192.168.4.1 will show up in the window. This means your Robot car has a Wi-Fi Hot Spot name “osoyoo_robot”, its IP address is 192.168.4.1
(3)Now your Robot car become a Wi-Fi Hot Spot and set IP address as “192.168.4.1” to your APP Setting section.
(4) Connect your cell phone to “osoyoo_robot” Wi-Fi hot_spot, and you can use the Mobile phone to control the robot car.
(5)You can click the ◄ ► ▲ ▼ direction keys to make the car move. Use “||” pause key to stop the car movement.
Click Obstacle to shift left side, Click Tracking to shift right side.
Click F1 to make upper-left diagonal movement, Click F3 to make upper-right diagonal movement
Click F4 to make back-left diagonal movement, Click F6 to make back-right diagonal movement.
In STA mode, robot car does not work as a Wi-Fi hotspot. Instead, it will become an internet node in your LAN. You need to tell Arduino sketch what is your local router’s Wi-Fi SSID and password, then Arduino talks to the router and get its own LAN IP address from DHCP server. You can use a Mobile APP to access the robot car’s IP address and control its movement.
(1) Unzip the m2-lesson5 file, and you will see a folder named m2-lesson5B, then load the m2-lesson5B.ino code into Arduino
(2) You need to change the code Line 176 and Line 177 :
char ssid[] = “YOUR_ROUTER_SSID”; // replace this with your router wifi SSID
char pass[] = “YOUR_ROUTER_WIFI_PASSWORD”; // replace with your wifi password
(3) Upload the sketch to Arduino. Finally, click the Serial monitor window in upper right corner of Arduino IDE, you will see following result:
(4)In this mode, you will see an IP address, which is our LAN IP address assigned by my router. Please write down this IP address and click Setting to set up robot IP address and set this IP address to your APP Setting section (no need to change default port 8888 in APP).
(5)Now your Robot car is connected to your LAN, you can use Mobile phone under the same LAN to control the robot car. If your APP is in WAN, you need to go to your Router Control Panel, forward Port 80 to Robot car LAN IP address, then you can use Router IP to control the car. This feature makes our robot car A REAL INTERNET OF THING device
(6)You can click the ◄ ► ▲ ▼ direction keys to make the car move. Use “||” pause key to stop the car movement.
Click Obstacle to shift left side, Click Tracking to shift right side.
Click F1 to make upper-left diagonal movement, Click F3 to make upper-right diagonal movement.
Click F4 to make back-left diagonal movement, Click F6 to make back-right diagonal movement.
FAQ about the WIFI UDP APP and sketch Code:
Q1)How to tune the robot car speed?
A: If you want to change the speed performance of the robot car, please following parameters in line 11 to 13:
#define SPEED 150
#define TURN_SPEED 150
#define SHIFT_SPEED 140
SPEED value determines forward moving speed
TURN_SPEED value determines turning speed
SHIFT_SPEED value determines parallel shifting speed
Q 2)What happened when you press buttons in OSOYOO WiFi UDP Robot Car APP ?
A: When you press a button of the APP, the APP will send a single-letter message through UDP protocol to the target device (in this example, our Arduino WIFI Shield)
Button | UDP message |
F1 | F |
F2 | G |
F3 | H |
F4 | I |
F5 | J |
F6 | K |
▲ | A |
▼ | B |
► | R |
◄ | L |
square | E |
obstacle | O |
tracking | T |
Q3)How does Arduino handle the UDP command?
Line 233 to line 250 in m2-lesson5A.ino file are the codes which react to Cell phone command. For example, when ▲ is pressed, according to Q1 table, a letter “A” command was sent from Cell phone to Arduino. Line 233 case ‘A’ …. statement will make the car make car moving forward.
char c=packetBuffer[0]; switch (c) //serial control instructions { case 'A':go_advance(SPEED);;break; case 'L':left_turn(TURN_SPEED);break; case 'R':right_turn(TURN_SPEED);break; case 'B':go_back(SPEED);break; case 'E':stop_Stop();break; case 'F':left_shift(0,150,0,150);break; //left ahead case 'H':right_shift(180,0,150,0);break; //right ahead case 'I':left_shift(150,0,150,0); break;//left back case 'K':right_shift(0,130,0,130); break;//right back case 'O':left_shift(200,150,150,200); break;//left shift case 'T':right_shift(200,200,200,200); break;//left shift default:break; }
DownLoad Url osoyoo.com
You must be logged in to post a comment.
I am a big fan of this robot. I already have three Models M1. I just received my first Model M2. I appreciate the improvement with the “Model Y motor driver” and the “copper wheel coupling”!
But I have a problem with the wifi connection of this new robot. It is losing more than 70% of the UDP packets, both in emission and reception. Is there anything I can do to improve the reliability of the wifi connection?
The wifi shield is the same as in my previous robots (firmware v1.5.4). The other robots are working ok with maybe only 5% of packet drops. So it is not a problem of network overload. I tried to put the robot very close to my wifi router (about 1 meter) but the packet drops have only reduced marginally.
Controlling the robot through wifi is crucial to my project. Any help would be much appreciated
I finally solved the problem by replacing the Arduino board. It’s strange because the original Arduino board seems to work normally for everything except this wifi communication issue.