Это видео недоступно.
Сожалеем об этом.
Controlling Elegoo Robot Smart Car with ASIO and C++
HTML-код
- Опубликовано: 17 авг 2024
- Elegoo very kindly sent me a Smart Robot Car Kit 3.0+, it's bundled with sensors and an Arduino. I though it would be a fun follow up to my robotic arm video, and build a small application using ASIO to control it.
The car: www.amazon.co.... use "UKjavidx9" for 20% discount until 9th November 2020
Source: github.com/One...
Slow Build: • Robot Car Slow Build
Patreon: / javidx9
RUclips: / javidx9
/ javidx9extra
Discord: / discord
Twitter: / javidx9
Twitch: / javidx9
GitHub: www.github.com...
Homepage: www.onelonecod...
"and they almost killed me with a screwdriver"....
Proof! clips.twitch.tv/SnappyRoughButterPeteZaroll
This is so much the internet
the police report would be both hilarious and tragic lol
@@javidx9 When do you stream normally?
I stream more on discord these days as it's a bit more interactive, but I like streaming on twitch too and should do it more often.
having a real device (like a motor or led) do something after clicking a button on your screen... it's got to be one of the most satisfying things ever
Lol for 20 years I've been doing this, and that first led that blinks is still an awesome feeling, it never goes away 😄
It is time to impelement face recognition on to this little beauty.
Having only programmed desktop software for years, I find this AWESOME AS HECK. Embedded systems seem like a lot of fun. I should buy myself an Arduino
Hey javidx, really appreciate your knowledge in your videos, as it has helped me so much with my programming and computer sci knowledge.
Just wanted to say thanks for your effort in your videos! :)
Thats much appreciated Diggerz :D Thanks!
oh i built one of these before :) . I became known as the strange kid at my college who would always get stopped by security and bad searched. I was the embedded systems lead and the president of my colleges tech club, and would walk around with a hiking back with drones and this guy strapped on the outside with bungee cord XD. inside my bag was tons of electrical equipment. it didn't take long for all the security to know me. AS A SIDE NOTE: !!!!! I SEE YOU USED THE ARDUINO IDE AND SWAPPED OFF TOO VS, TRY OUT THE "ARDUINO PRO" IDE. It has a lot of new features and integrates with git repos directly and a lot more.
oh boy oh boy oh boy, i cannot tell the level of excitement when i saw the video in my recommendations :D
javidx9 is type of person we all want to be like.
Just lovely. I'm looking forward to seeing more on the car programming and sensors.
Greatly anticipating getting into this stuff! 🙂
1. Cool hacking of the bluetooth software protocol and the hardware replacement :)
2. This car seems to be too fast/agile for AI based control. And has lots of provisions for future upgrades.
3. I was surprised to see a sponsored content, but no problems, another great video altogether. :)
I'm ok with sponsored content providing 1) They dont push me to be favorable towards the product, 2) it's in some way relevant to the channel 3) I can extract some sort of informative content from it and 4) They put me under no obligation to even use it. In this case Elegoo said, "here's a car if you want it, it would be nice if you used it in one of your videos".
Just downloaded a book to learn boost asio....been looking to apply my c++ knowledge and after learning a little about games, I immediately realized it’s not for me...but this (network and IOT) is really something I love.
Founded your channel two days ago. Very interesting content with C++.
Found it today Lmao! i got shocked
Awesome! Next step: interface with a steering wheel and pedals controller. :)
Hmmm.... I have those things 🤔
@@javidx9 Perfect! ;D
You can't do that, you would cause the fun buffer to overflow and the system would crash
@@javidx9 Pair those up with a camera rendering to the pixel game engine and you could literally drive it.
18:39 I think I came into the wrong video looking to learn about how to communicate with hardware. Still a very fun video and a great example of how pixel game engine can be used as a GUI creation tool for quick projects and to test ideas. Thanks for the vid Javidx
Your content is great and unparalleled!
The gateway into unboxing videos 😧
Twitch almost trying to kill you with a screwdriver is such an Internet thing to happen.
Great video as always, been following for some time now trying to get back on track with my programming skills (which are awful but i'm still pushing forward).
My wife is a programmer and we are both quite passionate about technology/ robotics/ sci-fi, etc (geeks to make it simple) and we also have an Arduino car, this might prove an interesting project, our original idea was to buy a couple more Arduino kits, mix a couple of parts and see what we could come up with. You really inspired us! Cheers! ;D
On the video description, please check (even though it's not that important or relevant but it's indicated that the discount is only in effect until 9th of November of 2011 ;D
Keep up the amazing work!
*Summary*
This video focuses on controlling an Elegoo Smart Robot Car Kit 3.0+ using a custom C++ application powered by the ASIO library and the olc::PixelGameEngine.
*1. Introduction and Robot Car Showcase (**0:00**)*
* Recap of a previous video controlling a robotic arm and introducing the concept of hardware programming. (0:00)
* Unveiling the Elegoo Smart Robot Car Kit 3.0+, acknowledging its sponsorship for this video. (0:51)
* Unboxing the kit and showing the components: Arduino board, sensors, motors, chassis, etc. (2:03)
* Demonstration of the pre-programmed robot using the infrared remote: forward/backward movement, turning. (7:01)
* Testing the obstacle avoidance mode (using the ultrasonic sensor), observing its limitations. (8:14)
* Overview of the official mobile app for Bluetooth control, but the goal of this video is to build a custom PC application for that purpose. (9:39)
*2. Analyzing the Pre-existing Bluetooth Program (**10:13**)*
* Looking at Elegoo's provided code examples and tutorials, specifically "Lesson 2: Bluetooth Car". (10:25)
* Examining the provided Arduino code (11:16):
* Motor control using Pulse Width Modulation (PWM). (11:22)
* Basic functions for forward, left, right, and backward movement.
* Simple communication protocol using UART (Universal Asynchronous Receiver/Transmitter) at a baud rate of 9600. (12:13)
* The code listens for single-character commands ('F', 'B', 'L', 'R', 'S' for forward, backward, etc.). (12:38)
*3. Building the Control Interface with PixelGameEngine (**13:12**)*
* Creating a `sButton` structure to represent clickable buttons in the application. (13:35)
* Adding `Clicked()` function to `sButton` for detecting clicks. (13:48)
* Adding a `DrawSelf()` function to allow buttons to draw themselves, including text (centered) and borders. (13:53)
* Utilizing the `olc::PixelGameEngine::DrawStringProportional` function for visually pleasing text rendering (new feature demonstration). (14:37)
* Instantiating and positioning four buttons: forward, backward, left, right. (15:21)
*4. Setting Up ASIO for Serial Communication (**16:22**)*
* Linking ASIO and defining preprocessor macros to avoid warnings. (16:25)
* Creating an ASIO `io_context` object (`ioContext`) (16:59) and a `unique_ptr` to a `serial_port` (`port`) (17:05) for managing communication.
* Handling serial port creation and configuration:
* Instantiating `port`, specifying "COM3" (determined based on device manager). (18:03)
* Setting port options using `set_option`:
* Baud Rate: 9600 (matching the Arduino program) (18:45)
* Character Size (8 data bits), Stop Bits (1), Parity (none), Flow Control (none) - standard UART 8N1 protocol (19:11).
*5. Asynchronous Reading with ASIO (**20:11**)*
* Creates the function `AsyncReadFromPort()` (20:28) to asynchronously read single bytes from the serial port:
* Utilizes `serial_port::async_read_some()` (20:41) with a one-byte buffer (to process individual characters).
* Lambda function (provided to `async_read_some()`) prints received bytes and then re-primes the `io_context` by calling `AsyncReadFromPort()` again, creating a continuous reading loop.
* Calls `AsyncReadFromPort()` initially in `OnUserCreate()` to initiate the asynchronous reading process (21:50), and starts the `io_context` thread (21:55).
* `OnUserDestroy()`: Includes logic to:
* `cancel()` the serial port. (22:40)
* `close()` the serial port (22:46), wait for the ASIO thread to finish (22:59), and only then safely reset the `port` pointer. (23:28)
*6. Testing Communication with a Bluetooth Terminal App (**23:35**)*
* Demonstrates communication between the PC application and a mobile phone acting as a Bluetooth UART terminal: sending and receiving text. (23:53)
*7. Adding Functionality for Writing to the Car (**24:32**)*
* Checks for mouse button presses and whether a button (`sButton`) is clicked. (24:38)
* Uses `port->write_some` to send single-character commands to the car when buttons are pressed: 'F', 'B', 'L', 'R' (25:09)
* Sends 'S' (stop) when the mouse button is released (25:37), making button presses momentary actions.
*8. Replacing the Bluetooth Module and Testing Car Control (26:33) *
* Explains the Elegoo module's limitations - it's hardwired to work with only their phone app. (26:33)
* Switches to a more generic Bluetooth module (previously used for the robotic arm project).
* Demonstrates successful car control: forwards, backwards, left, and right (using the PC app to send commands and observing real-time responses).
*9. Future Possibilities and Outro (**29:03**)*
* Briefly explores exciting future possibilities, such as incorporating sensor readings, line following, more complex control mechanisms, and potential for letting viewers on Twitch control the car.
* Thanks Elegoo and encourages viewers to consider purchasing the car, providing a discount link in the description.
*Key Takeaways:*
* The video demonstrates a real-world use case for ASIO to control hardware wirelessly via Bluetooth using serial communication.
* By analyzing existing code examples, it's often possible to figure out protocols and adapt existing implementations.
* Designing classes that encapsulate their logic (`sButton::DrawSelf()`) makes larger projects more manageable.
* Understanding the importance of properly managing asynchronous operations (canceling, waiting, and resetting) is crucial for preventing potential errors, especially in hardware control applications.
i used gemini 1.5 pro to summarize the youtube transcript
I got one of these cars as a Christmas gift a while back, and was quite interested in how the included Bluetooth module worked. It turns out that it is not proprietary or anything like that, instead it is actually a "Bluetooth Low Energy" or BTLE device, which to my surprise is not at all compatible with traditional Bluetooth, and to interface with it requires writing an application to use the BTLE API with a BTLE compatible adapter. In my case, I used a Raspberry Pi with it's embedded wireless module and an BTLE library for Python to write a little program to control it. Which was a little more involved, but gave me the ability to send data wirelessly. I made my program visualize all the sensor outputs, including the Ultrasonic readings, as well as drive with the keyboard. It was fun for awhile, but it ended up finding a home on a shelf after a month or two.
You're an absolute legend, do you know that
javidx9 is godlike o7
I made this same car as a kid!!! That was only a couple years ago but still very cool video!
Beautiful video and very informative. As a robot enthusiast.
Cool, A hardware vid. I’m out the back of Bungaminfi (a place I made up), and can’t watch, but looking forward to it. I hope the smart part is robot arm throwing vehicles in front off the road.
Damn, wanted you to put it all together, add WASD movement and a camera on it which streams to the pixel game engine and then drive it around.
It's an ultrasound sensor at the front, but maybe the camera for the line following parts could work
That would be a fun second project. I'll probably let the twitch chat control that 😄
Yes, this is an opportunity to start involving OpenCV :)
@@javidx9 I think it would be super cool if you could have it display out the radar feed on desktop and use that to navigate!
In some alternate (perhaps nonexistent) universe where people start their coding journeys not by printing "hello world" to the console, but instead by outputting"hello" through the speakers, I guess they use javidx9's "hello" sound recording because it is friggin awesome.
Holy shit this looks fun and like something I could do in CPP. Time to crack out my Arduino!!! :D
Nooooo you killed it!
Thanks for another great video javidx! I keep thinking of trying to do some small hardware projects such as this myself, but somehow never quite seem to be able to find the time, or indeed the space! :-)
Please make playlist for beginner c++ for robotic....🙏
Bravo, Mr Javidx9 your are a Genius! :-)
It would be interesting if you make a video about the new Elegoo Smart Robot Car with Camera v4, explaining how to connect to it using ASIO :-)
amazing mate! even I hope to make a hobby of making robots...
It is soo cool!
Nice! I would really like it if you made a video on rhythm games; it would really help me out!
Yeah, I think this will happen next year, its an idea that I think should be really easy to implement
At around 27:00 you're mentioning how it makes sense for the manufacturer. I do have to disagree there slightly. Back in the day, these things/kits were all about figuring it out for yourself. A kid learned a ton from that, these days I only seem to see these kind of products that are just about bringing some components together like a jigsaw puzzle and then by magic it works. There's no learning in that I think.
Other than that I love this and your other videos a ton! :)
Sure taking something that doesn't work and making it work can teach you a lot but I don't see why all products should arrive in that state. You can still play around with Arduino code and the components on your own even though it arrives in a ready to run sort of fashion. There is always the choice of buying the Arduino board, servos and other misc components separately.
Bring on the C++ interfacing that’s where things get real :-)
Time to implement a mapping function for your kitchen now!
Lmao
Melhor canal de todos, você é melhor.
Great video, been following your channel since I decided to give C++ a go and was looking at this kit to play with.
Do you have any recommendations for someone wanting to learn embedded systems programming?
Thanks Pedro. Regarding beginning embedded systems, it's much easier if you are familiar with programming generally first. That's because embedded only introduces new things to worry about, as exploiting embedded properly also requires an awareness of electronics.
you are the best
That video was cool
Mancave made my day!
C++ top!!!!
Very good.
On the next time-lapse I would like to recommend Danzon No. 2.
Please make a video on video games reverse engineering. That would be appreciated
Very nice. I have a few Elegoo products. Pretty good stuff. Sometimes the documentation is organized a bit odd, but usually all the information is there.
I also happen to want to transition to embedded programming, so I'm totally looking forward to anything you do with this!
Can you make a starters guide to what path we can move on about programing in general. I'm a Mechatronics Engineering second year undergraduate at a small university and I'd love to improve my coding from cmd c++ skills but I don't have any project idea or any path to follow and I found all the information in internet quite hazzy and quite ITish. I hope you see this comment, I really want to improve myself like how you improved yourself about robotics.
I read every comment 🙂 hmmm, it's a good idea, a video that perhaps lays a bit of a road map for programmers. I'll give it some thought.
We’re you able to use C++. Awesome! A serial port?
🎯 Key Takeaways for quick navigation:
00:00 🤖 *The presenter introduces the video, reflecting on a previous robotic arm project and expressing interest in embedded systems.*
01:07 📦 *Elegoo sent a Smart Robot Car Kit 3.0+, and the video will cover unboxing, assembly, and programming. A discount link for the kit is mentioned.*
01:35 🛠️ *The robot car kit includes features like Bluetooth control, line tracking sensors, obstacle avoidance with ultrasonic sensors, and an Arduino-powered platform.*
06:04 🚗 *The presenter demonstrates the pre-programmed functions of the robot car, including forward, turning, and obstacle avoidance using an infrared remote control.*
08:31 🔄 *Testing ultrasonic sensor-based obstacle avoidance mode, showing the car scanning in three directions, with some limitations in resolution.*
09:44 🎮 *The car can be controlled via Bluetooth, and the presenter plans to explore using ASIO and C++ to communicate with the car from a PC instead of using the provided phone app.*
10:56 📖 *Exploring pre-made programs provided by Elegoo for the Arduino, starting with lessons on building and controlling the car, with a focus on Bluetooth control.*
13:17 ⌨️ *The presenter creates a Pixel Game Engine application with on-screen buttons to control the car via Bluetooth, intending to explore ASIO for Bluetooth communication.*
20:14 🔄 *Implementing asynchronous communication with ASIO for reading bytes from the serial port, allowing the PC to respond to data sent by the robot car.*
23:02 🛑 *Ensuring proper cleanup in the Pixel Game Engine application, closing the serial port, and waiting for asynchronous tasks to complete before erasing the port pointer.*
23:58 📲 *The presenter establishes a Bluetooth connection between the Pixel Game Engine application on the PC and a phone, successfully sending messages from the phone to the PC.*
25:06 🕹️ *The Pixel Game Engine application is modified to send commands (forward, left, right, backward) to the robot car via Bluetooth when on-screen buttons are pressed.*
26:43 ⚙️ *The original Bluetooth module provided with the Elegoo kit is found to be configured for the mobile app only. The presenter replaces it with another Bluetooth module for PC control.*
28:11 🔄 *The presenter successfully controls the robot car using the PC application, demonstrating forward, backward, left, and right movements. The car is now responsive to PC commands via Bluetooth.*
29:41 🚗 *The presenter expresses excitement about the potential of the Bluetooth-controlled robot car and mentions future possibilities, such as using sensors and letting Twitch chat control it.*
Made with HARPA AI
I have always had a dream since I was younger to build a Rover robot and just let it go on Earth with GPU tracker and video I can retrieve. Would be so much fun letting it go in the middle of the woods and see how long it will go.
Awesome
I always do robotics with C, Rust and raspberryPi, but I think I'm going to start using C++ and ASIO :D
perhaps i am a newbie one! is there a way to learn it online? i want to be ahead of my class!
@@justasydefix6251 I just recommend the rust embedded tutorial in rust-lang.org for embedded devices programming and the rust_gpiozero library for raspberryPI
I'm definitely going to buy one of those xD
yes embedded systems!!
gracias
thank you!
Check SMARS robots if you have a 3D printer. They are very similar but a lot smaller and cheaper. And there is plenty of modules available for them. But most importantly they are cute :)
Great video as usual! But I can't understand how just opening a port object takes care of finding another device, negotiating communication and stuff. How can the other device even discover the name of the other device?
Could you do something on sending and receiving data via Bluetooth using C#?
I think I’m finally getting asynchronous thinking
Given that you can get mbed boards very cheaply that match the arduino uno's pinout and form factor: would it be worth explaining how to do some surgery on this to make it work with the mbed platform and use that as a vehicle for talking about different embedded platforms?
Interesting video. I bought Elegoo smart robot car v4 with camera (wifi). I would like to be able to control the robot car, rather than with the smartphone, with the pc via wifi. From the pc I can connect to the wifi spot of the robot, now how do I have to do to be able to receive data on the pc and send data from the pc to the robot car ? I wonder if you'll want to make a video about this...
Can you do analog controls? That would make for a great video
Wasn't ASIO meant for multichannel audio data transfer :D
BigBang thoery robot arm next
neat
Description: use "UKjavidx9" for 20% discount until 9th November 2011
Time to go back to 2010 to use the discount
Amazing!
Could you make multithreading collisions? no body made a video about that, thanks
Can you teach me how to write drivers for proprietary Bluetooth devices if I have the packet data? Specifically Dualshock 4 controller's on board speaker, audio jack and optionally mic
What do you know I just bought this exact kit to try ML by mounting a Jetson NANO
14:20. Haha Final Fantasy Reference.
Could you tell me the name of the app you installed on your smartphone to monitor the serial data sent by the RobotCar1 program in the initial phase of your tutorial ?
Its called serial Bluetooth terminal for android
@@javidx9 Thank you. Now I see the string sent by RobotCar1. Can this be done using WiFi instead of Bluetooth, having a wifi card instead of bluetooth on the robot ?
Yes, but WiFi is an ethernet based thing, so you'll need some sort of tcpip stack running on the car, which is possible, but far more complex. The Bluetooth modules are a posh com port, so nice and simple.
@@javidx9 In version 4 of the Elegoo Smart Robot car with camera, there is already a sketch on the robot that manages WiFi with TCP/IP. That's why I asked you how to do with ASIO. The problem is that they have made a communication protocol towards the robot, different from the simple one for bluetooth, and this is where I have difficulty communicating with him....
Very good tutorial,
Btw I also use boost::asio::serial_port a lot in my desktop apps development.
I am only wondering about boost.beast for serverclient communications, what about it, is it worth a try!? Have you trid it!? or should i stick to only boost::asio?
TIA.
Too bad discount was only valid until 9 years ago :(
Hello javidx9, I was wondering if you could make C++ AI & ML series. Plssssssssssssssssssssssssssssssssssss!!! I can't find any tutorials or courses online, you are my only hope
"This item cannot be shipped to your selected delivery location. Please choose a different delivery location. " :(
:“”C
Superb project Javidx9! We loved it so much that we featured it in this weeks episode of The Electromaker Show: ruclips.net/video/UlmoWjUt4Fc/видео.html
Thanks! I was unaware of your output until now, but had a quick rummage through your channel and I've a whole host of things to watch over Christmas now 🤣
@@javidx9 Haha you're welcome! Glad to hear we can keep you entertained over the festive weeks :)
how about writing some AI code to have the bot keep and update a 2d map of the world.
*Hi JAvIDX9* got something fun to share. My first computer was commador 16k (thats right 16k before the 64k ones!!!). In the older days when bbc basic computers came out, our school teacher set up 20 computers to a network hub, which was something new then. Internet had not been invented. Somehow me and my mates realised we could send the hub some code and then be able to take control off and write on other peoples screens. Thus we proceeded to place F*ck//A*se/Tw*t into peoples homework whilst they didnt know. hehehe.... We got told off and sent to the head masters who said "Thats very bad ~ cleaver and well done you ~ but very very bad" lol. Cant do this complicated stuff, just thought id share, all the best
Isn't this 'paid advertisement' then (0:55 - 1:05)?
If so you should probably have a marker somewhere that is constantly saying 'Advertisement'.
That's at least what most youtubers do.
You might get trouble otherwise, wich would be a bummer.
There's a box to check, it works for existing content without resetting view counts etc. which automatically adds the includes paid content notice.
If someone flags this video it will be a pain in the arse, because RUclips can take down the whole channel.
After reading the guidance from RUclips, it was unclear. The car was provided, because they would like me to use it in a video. Obviously they get some exposure, but there was no obligation to speak favourably or indeed review the product. In that case, I'm not actually "promoting" it. That said, I'll mark the video as paid promotion.
Open RUclips: javidx9 video uploaded 7 minutes ago
GoGoGoGoGoGoGoGo
That would be so cool for streamers if it connects to airpods LoL
Imagine using a poll as a twitch streamer whilst connected to airpods and the majority vote from chat moves with respect to locations of a jungler
Could the programming be done in python ?
look into socket library
Whilst i am trying to figure out
How he get:
Z((z far/ z far - z near) )-(z far . z near/z far - z near)
He came out with new video
Perhaps, at one point... you could make something with the Bela Platform bela.io/
Very good info... But without this robot its not useful.
Instead of making video of some company specific robot, you can create video about Arduino, microservo concurrent handling,
Rtos basics on Arduino (simple way), how to speed up program, Arduino Ethernet lib development etc.. trust me there is whole community waiting for so long to get easy tutorial👍🏼
serial communications via asio is not useful?
Indeed useful, and thank you very much for that i will try 🙂. I actually aked for Arduino specific tutorial. Your teaching will be really helpful for Arduino users. (Just a thought)
@@liveoutlive7588 Thanks, I've very little experience with the arduino platform, I tend to favour the mBed platform instead - though I agree, some more hardware videos would be nice to make
Mbed is good platform, but ArduinoUno is ~$5 board(clone or diy version). it is very cost effective and safe to play with it.. and think Arduino with other ~$2 0.9inch oled display!!! + Your olc graphic engine!!! This will be revolutionary :).
And Arduino community is way larger than anyother because of its simplicity and cost.
I hope you consider this over mbed. I know mbed supports c++14. But anyway i really enjoy techniques and explanations.
Have a good day!
Ъ