Software apps and online services
Hand tools and fabrication machines
In short, this robot will follow any object that comes close to it within a range of 20-50 cm, and if none is found, it will first try to find lost objects on the right and left sides with the ultrasonic module. But if again without results, then turn right and try to lock onto an object nearby. I would like to do more with it, like let the car figure out how to drive around the obstacle, but for now I'm happy with the fact that under some circumstances the car can find an object.
With this information, we can instruct our robot to turn accordingly and avoid losing the target object. I didn't know if anyone had already built something like this. I was just trying to tweak the sample codes that a SmartCar manufacturer provided with the product. Using the sonar sensor the way I was using it caused a jamming issue (I was pretty sure it was a timing issue) which luckily I've resolved.What you need
For this project, we will only need a four-wheeled robot with appropriate motor drivers, an Arduino Uno board, a micro servo motor, and an HC-SR04 ultrasonic sensor.
By using a ready chassis it is possible quickly build a working model. If you buy "Robot Smart Car Kit" that includes a chassis, wheels, motors and other mechanical components, to build the robot, we will need only few additional electronics to control the motors and sensors to detect obstacles. The whole electronic design was made based on the Arduino Uno.
At the end we add batteries and charger to power supply the robot and the all will be ready for using. build a chassis
For more details about ELEGO smart car see page: hier . Download and unpack the ElegooCarV3 packageHow does the Ultrasonic Sensor SRF05 Work?
This is a very simple and useful ultrasonic sensor. It detects distance: 2- 450cm, high precision: up to 0.2cm. There are four pins that you would use to interface with the sensor: VCC, Trig (signal output pin), Echo (signal input pin), and GND.
The best measurement results are obtained with reflection on smooth, flat surfaces. At distances of up to 1 m, the material of the surface is quite uncritical. For short distances, the angle to the object can be less than 1 m to around 45 °. Even very thin objects are reliably detected. At the maximum distance of 3m, you have to aim precisely and there should be no other objects at a similar distance in the transmission cone of 15 °.
To rotate the sensor you can use a micro servo. This allows you to monitor the entire front of the room. The picture shows covered rooms when the sensor is set up straight (90 °) and 65 ° or 115 ° (pink and gray area).
Our robot will try to stay 20 centimeters behind the target object, moving forwards and backward depending on the target’s position. If either side is three centimeters further away than the other, the robot will turn in that direction to follow its predicted path.
If the detection is limited of objects to distance0.5 m, and considering that the angle to the object ° at short distances (less than 1 m) is around 45°, the space in front of the Robot Car can be monitored well. As can be seen in the picture, when the ultrasonic sensor is positioned at 55 ° (left) monitored room is from 32, 5° to 77, 5° and so is similar for 115 °(right), the entire room is monitored from over 120 °.
During an object search, the ultrasonic sensor can be positioned at 10 ° for the left and at 170 ° for the right side. In this case, the space covered is almost 210 °. For an extended search for an object, you have to turn the robot car to get the object you are looking for in sight. Once the object is in sight, the Robot car has to take care to keep it at a certain distance. I have defined that as a fixed value. A normal distance is defined 30 cm (as NOMDISTANCE = 30), the minimum distance is determined to be 20 cm (as MINDISTANCE = 20) and determined to be dangerous close to 10 cm (as CRITDISTANCE = 10). Space within a radius of 50 cm is monitored, (as MAXDISTANCE = 50).
That's enough for object tracking, but not sufficient for object recognition. Additionally, the robot car has no knowledge of its surrounding so it will not avoid obstacles. Of course, you could also first learn with the Environment program and thus display a room image, but subsequent positioning in the direction of the object is imprecise as it depends on the floor area.
Using a camera can solve this problem, but that's the subject of our next tutorial.CODE
Our robot can execute four actions:
- • Forward
- • Left
- • Right
- • Stop
Accordingly I have made subroutine:
Keeping distance keep the distance to the object between 20 to 30 cm. If the object is far, the robot car moves forward. If it got too close, the robot moves back.
Follow object detects object in the front room.
Search Object searches for an object when it is not in sight. Only at the edge of the front room (sensor position 10 ° and 170 °) and if unsuccessful then the search is continued through the turn.
I've prepared examples of Arduino programs for you (all available at GitHub). In the program the robot car operates autonomously following the object.
The Follow me program contains the part Keeping distance, from where are called other subroutines, as shown in the picture.
const int nomDistance=30, minDistance=20, maxDistance=50, kritDistance=10;
If you want to search for the closest object, it would be necessary to make the appropriate change in Program Object search, but in practice this can slow down the execution of the program.
The corresponding change in the Object search program is shown in the picture. Instead of exploring all objects at a distance of up to 0.5 m, you can also start from the closest distance to the far away. A simple program is easier to integrate into a more complex, larger program.
The attached programs allow you to test the Program Follow me with Sensors and actuators. However, if you prefer to control the robot yourself, use a ready-made program, make the appropriate change, and just upload it to your robot.