DIT112-V20 / group-05

MIT License
1 stars 0 forks source link

Gyroscope #117

Closed JakobRoseke closed 4 years ago

JakobRoseke commented 4 years ago

https://github.com/DIT112-V20/group-05/blob/41e33afd948e51c8bc6deb598ebc4ffbdb266f74/src/smartCar/smartCar.ino#L59

Hello! We have come up with a function that we believe will help us with knowing when the car has reached the destination, however, we need the heading of the car for that.

We've got some questions about how the gyroscope works. Does the offset change every time you start the car? If it does, how would you indicate that? Would the code linked above work for something like that? (Together with line 33 and 34)

platisd commented 4 years ago

The offset does not (substantially) change across power cycles. Just find out what that value is once (e.g. by using the example sketch) and then provide it to the gyroscope's constructor.

Aside of that, I cannot see how what you have would work in the way you described/intended in any programming language I know of. :scream: :grinning: (OK I am lieing here, I can think of a way but it would be particularly unintuitive and a definite code-smell)

JakobRoseke commented 4 years ago

The offset does not (substantially) change across power cycles. Just find out what that value is once (e.g. by using the example sketch) and then provide it to the gyroscope's constructor.

Aside of that, I cannot see how what you have would work in the way you described/intended in any programming language I know of. 😱 😀 (OK I am lying here, I can think of a way but it would be particularly unintuitive and a definite code-smell)

I can see your point. Our system is merely a prototype of what we would have wanted but to make use of what we have we decided on how it would work in a interesting way, at least in our opinion :)

The short explanation would be that the car would get a destination input from the application, giving it a distance (in our case, centimeters). The car would then travel that distance on the most IDEAL path. In reality, that path would be instructed by something like Google Maps, but in our case, due to lack of hardware, that path would be a "straight" line. From our code, we have the original heading be indicated from the first starting point and as long as the car is within 10 degrees of that heading it is counted as going towards the destination. Otherwise, it is going in the incorrect direction. Now with this information, if the car is heading towards the incorrect distance, the distanceToDrive changes to the originalDistance + the distance the car driven in the incorrect direction. Otherwise, the distance the car has been going the correct distance gets increased. When the correct distance the car has driven equals the distance to drive, the car has reached its destination.

This is by far a perfect system, but it visualizes and represents the car going in the most ideal path towards the destination.

Also, thank you for the information! 👍