What Libraries Do I Need?

Hi Everyone,

I just wanted to get some quick guidance on what libraries I will need to use for a robot I'm building. I'm using an ATmega 2560 with a built-in ESP8266, an L298n with 2 motors, and 3 servos. The robot has two tank tracks and a movable arm with a claw. I also want to use a voltage divider to monitor the lipo battery I'm using and to stop the robot when the battery level is getting too low.
The robot will look like this

Here is the ATmega I'm using

My goal is to build a robot that is connected to the wifi and then controlled via a computer keyboard. I know that I need to set up the ESP with the wifi username/password, and then pass the keyboard commands to the mega via the TX/RX. The mega will then take these strings and use an array to figure out what command to run.

I'm still quite new to Arduino programming and haven't used an ESP before in any of my projects. I was hoping someone could tell me what programming libraries I will need and if anyone has any advice on how to best program my robot. I've got a decent understanding of servos but I'm still quite new to all of this and could use all the help I can get.

Cheers!

Here's an example for a very similar robot. The relevant repos are :

DiscoBot - runs python on the PC for controlling
RobotMainBrain - a 1284P (similar to your mega) that handles onboard control
RobotArmController - controls the arm, what else?
RobotWifi_ESP07 - an ESP8266 that used for communication over Wifi
RobotSHaredDefines - some constants shared among the other codes.

Mine is controlled by a X-box controller on the PC. But it would be pretty easy to use a keyboard instead. Everything on the xbox controller in mine has an equivalent serial command.

@Delta_G
Thanks for posting the links. Do you have any photos of your project?

Did you write all of these libraries yourself?

I had a look at the DiscoBot code and I'm a bit confused as to how that works. Is that a program that you've installed on your computer or run via an online server? I tried looking for info on google but it kept coming up with Discord info.

Also, How do you run all of these codes? do you merge them into one file or do you have multiple arduinos running in your robot?

I really should start a thread in Exhibitions for this guy. I've been working on it on and off for a while now. I don't get a lot of time with it. Mostly just weekends here and there.

Here are some pics.

wernejo:
Did you write all of these libraries yourself?

I wrote all of the code myself

wernejo:
I had a look at the DiscoBot code and I’m a bit confused as to how that works. Is that a program that you’ve installed on your computer or run via an online server?

Either. It’s a program in python that launches a little GUI that gives me info about the bot. I hook my xbox controller to my PC or my Raspberry Pi running DiscoBot.py and it connects to the robot and sends the control info. It does some other stuff too. It can use Serial or the network (or the internet) to connect to the robot.

wernejo:
I tried looking for info on google but it kept coming up with Discord info.

Yeah, it’s not going to be anywhere except the github where I keep a copy of it. It’s just my thing. I just thought it might be interesting to you since it sounded similar to what you were doing.

wernejo:
Also, How do you run all of these codes? do you merge them into one file or do you have multiple arduinos running in your robot?

RobotMainBrain runs on a ATMEGA 1284P that lives underneath the robot on a piece of perfboard with a whole rats nest of wires. It controls everything.

RobotArmController runs on an Arduino Nano and it is part of the arm. I can unplug that board with two molex connectors and unplug the power with an XT60 and take out a few screws and the whole arm comes off along with the controller. I can hook that up with a USB to my computer and play with the arm without the bot if I want.

RobotWifi_ESP07 runs on an ESP8266. It does a few things. It mainly sets up a serial to TCP bridge. RobotMainBrain is pretty agnostic when it comes to what sort of communication we have. It just sends serial. I can use a USB-ttl converter or this code on an ESP8266, or a LoRa radio or whatever to communicate with the robot. I like this sort of modular design. It makes things versatile. So this code is just reading serial and sending over a TCP socket and reading from the CP socket and writing back to serial.

So there are three boards and a computer involved in driving it. Could be less, but I’m thinking ambitiously.

@Delta_G that's an insane-looking robot!

I'm still looking at your code and figuring it all out but thanks for sharing that with me. How do you get all of these different boards to work together? Are you just using TX RX or is there another method of hooking them all together?

I've just started learning fusion 360 and am planning on redesigning my robot from the ground up. What kind of motors and batteries are you using? Also, was this a kit or your own design? I'm having trouble with the tension in my caterpillar tracks and am looking for solutions on how to fix that. Any ideas?

Delta_G:
I really should start a thread in Exhibitions for this guy.

Looks great.

...R

Hi,

@wernejo , can you tell us your electronics, programming, arduino, hardware experience?

Tom... :slight_smile:

@TomGeorge

Hi Tom,

My main background is in front end web development, so I have experience in coding, just not so much with Arduino. I'm also a member of a local hackerspace and I've been doing most of my learning and work there. Most of this is fairly new to me as I've only been doing this since Nov 2018.

So far, I've been able to develop a good comprehension of motor drivers and servos. The part that I'm unsure with is programing for IoT.

I've currently got my robot running by itself using a set of pre-programmed code and not remote-controlled. The next phase is to introduce the wifi component of the project.

wernejo:
@Delta_G that's an insane-looking robot!

I'm still looking at your code and figuring it all out but thanks for sharing that with me. How do you get all of these different boards to work together? Are you just using TX RX or is there another method of hooking them all together?

It's all done with Serial. Although if I add much more I'm going to run out of serial interfaces and probably switch everything to SPI or I2C.

I found it surprisingly hard to find good cat tracks for my bot. Sourcing the tracks was probably the hardest part of the whole endeavor.

Mine is completely remote controlled. There are a few automated tasks with the arm, but I'm controlling it all with an xbox controller hooked to my PC. My next move is to introduce some automation. I'll probably start with adding some sensors so I can try out self driving.

wernejo:
Also, was this a kit or your own design?

The tank chassis was a kit I bought on Banggood. It came with a node-MCU and some program to let you drive it from your phone. Well, kind of. The code was probably written by a monkey on acid with a typewriter. It didn’t work very well. So that all got ditched pretty quick and I built the 1284P to drive the bot with whatever style of communication I want. Right now I can switch it from LoRa to WiFi just by swapping out one piece with no code changes. Or I can plug a USB-TTL converter in and just run it direct serial from the PC, though it ends up tethered that way. Sometimes I stick a R-Pi on the back so it can carry the PC with it.

The arm was also from banggood. It came with some super weak servos though so some of those had to be replaced right off the bat. It had no controller, just the hardware and the servos, so I built a Nano to control the arm. I could have incorporated that code with the rest on the 1284P, but I like things being modular. Right now I can take the arm off and the 1284P just notices that the arm isn’t responding and goes on without it.