[SOLVED] Obstacle avoidance not works every time

@cleoqc have some error need attention please.
Code attached was shared by you but the distance or obstacle not works every time.
Even thou has obstacle it dashes…

Python_Self_Driving_Car-Drive_from_John_to_Nicoles-2.py (1.4 KB)

This code is a tad simplistic. The robot will check if the road is open ahead of it before starting, but once started, it no longer checks.

Thanks @cleoqc any solution to keep check all tym and stop when any obstacle all tym.

@chetuk , yes there are solutions. The goal of the forum is to help you learn to create those solutions.

The best way to learn is to

  1. Study to understand the existing program very well, every line, every variable, every command, every action the robot is making.
  2. Determine or guess what is not happening and when it needs to be happening
  3. Modify the program to make it do what you believe is needed
  4. Fix any programming language errors you may have
  5. Run your modified code to see if you have adequately fixed the problem you identified.

Additionally, perhaps you can tell us a little about yourself, and what you want to accomplish with the GoPiGo?

(I am not with Dexter Industries - a robot owner, I am.)

2 Likes

Thanks @cyclicalobsessive for the advice trying to get work currently on beginner stage.
Appreciate any hint or guidance to make the distance sensor worked.

Cheers!.

Any advice as want to present in university || please help||

@chetuk, It would appear that you do not understand that we do not understand specifically what you do not understand about your GoPiGo3 robot, such that we have no way to help you.

You asked “advice to get distance sensor working” and “check all tym and stop when any obstacle all tym.”

The expectation is that you will learn enough about the programming language you have chosen to know how to:

  1. Do something
  2. Check something(s)
  3. Decide something with the check(s)
  4. Repeat 1 through 3 optionally until something

You were given an example program that performs each of those steps.
a) Study it until you know what each line does.
b) Decide how to change it to do what you want the robot to do.
c) Modify the program and try it out.
d) If you have a specific problem with your program, post what the error is.

You state that you “want to present in university” and need help. Perhaps your professor can help you with that aspect?

There is an example project DI has on the robot - it checks all the time and stops when gets close to an object. Have you studied it? This is a link to the code on github, but it is also on your robot somewhere.

You haven’t told us which OS you are using, nor how you are working with your bot (remote desktop/noVNC, wired desktop, terminal from browser, remote ssh) so I can’t help you find it on the robot.

Are you working with your own GoPiGo3 or with a university lab GoPiGo3?
What is the name of the university course you are taking that is using the robot?

Thanks for your response,
Im using raspbian for robot OS working with NoVNC
Its a local university/school of kids just to show a demo where line follow , intersection and distance work all together .

maybe some changes in below script other than it works excellent.
Python_Self_Driving_Car-Drive_from_John_to_Nicoles-2.py (1.4 KB)

this function

"""
def GoToTurn():
	while my_Distance_portI2C.read() < 20:
		gpg.stop()
	gpg.forward()
	while not  my_linefollower.read_position() == "black":
		if my_linefollower.read_position() == 'center':
			gpg.forward()
		if my_linefollower.read_position() == 'left':
			gpg.right()
		if my_linefollower.read_position() == 'right':
			gpg.left()
	gpg.stop()
	gpg.drive_cm(7,blocking=True)

/Chetuk

a) Study it until you know what each line does.
b) Decide how to change it to do what you want the robot to do.
c) Modify the program and try it out.
d) If you have a specific problem with your program, post what the error is.

Yep, I have to agree on that. We are here to help people diagnose immediate problems, like syntax errors and installation-related issues and that sort of stuff.

We are not here to write other people’s code but encourage them to find their own way and explore it. By writing code for someone else is like depriving them of the freedom to have their own shot at the problem. It’s akin to preferring the movie adaptation of a book.

Anyhow, @chetuk, here are 2 of our documentations you should find helpful:

  1. https://di-sensors.readthedocs.io - in this one you can search for the line follower to find out more.
  2. https://gopigo3.readthedocs.io - and this one is strictly for the GoPiGo3.

Both of these documentations should be enough to give you a clear understanding of the line follower and how you can use it and the GoPiGo3.

Thank you!

My apologies changing thread to solved.
As well thanks for sharing above links .

/Chetuk

I’ll set a timer on the thread to automatically close in 1 day if you still happen to have some issues related to this.

Thank you!

This topic was automatically closed after 25 hours. New replies are no longer allowed.