We have built an obstacle avoiding robot using evive. We have mounted our ultrasonic sensor on a servo. So after detecting a collision, the robot analyses which direction is the best to go using distance at various angles from ultrasonic sensor.
Current Task in Progress
To develop it for obstacle avoidance plus direction follower so that our robot can go in a particular direction with avoiding the obstacle.
First of all the building part of it, then we will proceed to the coding part. You can see the image - how our robot looks like. This structure actually makes the work easier.
All the CAD files can be downloaded from our GrabCAD profile -
Connections to make
We have three devices to be connected to the evive.
To connect the two motors of the robot insert the wires of motors in the slot made in evive that are M1 and M2 in the correct orientation.
Now, we have to connect the servo motor in evive, in this we have not used the inbuilt servo pinouts because it uses the same pin as that of motor so instead we have used digital pin 9 for communication of servo and other power related pins to the arduino for example VCC to 5 volt and GND to ground.
To connect the ultrasonic sensor just connect the VCC to 5 volt, GND to ground and for trig pin and echo pin we have used the digital pins 3 and 2 respectively.
Please have a detailed look at the evive’s schematic pinout diagram, so that you can easily connect motors and servos.
Finding the best direction to go
Normally, while moving forward, the ultrasonic sensor ‘looks’ in the front, i.e. the sensor provides the arduino the value of the nearest distance that an obstacle is present in front of it.
As soon as this value becomes less than a minimum threshold, we stop the bot.
Then, we turn the ultrasonic sensor, once to the left and then to the right.
Each time, we obtain the distance of the nearest obstacle in the respective direction.
We store both of these values and calculate the maximum of these values.
Then, we turn our bot in that particular direction. This is the optimum direction, where the bot can travel the farthest without needing to stop and check again.
The robot starts moving forward, until another obstacle comes in front of it.
Changed Servo library and new motor library
Due to limitations of present servo library, we cannot use the servo along with motor drivers. So we have modified the servo.cpp file in Arduino/Libraries/Servo. Download the Servo library code here and replace the original library in Arduino IDE using this.
NOTE: evive uses PWM Pins 44, 45 for motors and the same are used for servos, so you CANNOT use plug and play interface for servo motor. You will have to use any of the 3 to 13 pin for connecting the signal wire of servo. ALSO since default servo library uses TIMER 5 (aka PWM pins 44, 45) for controlling the servos. SO PLEASE REPLACE THE DEFAULT SERVO LIBRARY IN ARDUINO LIBRARIES using the attached file “Servo.rar”. Please have a look at Schematic PinOut Diagram of evive here.
Now we need to include the motor library. Please find it here. It is very extensive in a way that it makes controlling motor very easy. Please look the motor.h for understanding the available functions in this library. Screenshots are provided for describing how to add a library to arduino IDE.
Supporting Material & Info
product info - http://evive.cc
pinout diagram - http://evive.cc/techSpecs.html
Product Video - https://www.youtube.com/watch?v=3F0_JspobN0
Github Repository - https://github.com/evivetoolkit/eviveProjects