Git Product home page Git Product logo

Comments (5)

Sarxell avatar Sarxell commented on July 28, 2024

Hi @vitoruapt and @miguelriemoliveira ,

So, me and @manuelgitgomes thought that it was very weird for the arduino only giving positive values so we decided to change the code to a more precise approach using two interrupts.
This worked! You can se a video when we drive 1.80m (the wheels' perimeter) and the pulses the encoder gives us:

pulses_2.mp4

Here is the car moving :

https://user-images.githubusercontent.com/92535336/170281740-b62c4b45-823a-4222-829d-8741e6e37692.mp4
(Beware, it has sound!)

We also send these values to the atlascar2 cmd_vel topic which the ackermann_controller uses to calculate the odometry so we can see the car moving in the simulation:
With the measuring tape we measured 1.50m (rough) and the simulation moved 1.63 , this needs more tests because the gazebo has simulated forces and inertias! With rviz and with longer paths we will be able to see more realistic results! We hope to do it next week when the eletric panel is completed

Screenshot from 2022-05-25 14-45-40

Screenshot from 2022-05-25 14-46-16

from atlascar2.

vitoruapt avatar vitoruapt commented on July 28, 2024

Fine! Double interrupt was after all a positive approach ;-)
@Sarxell A doubt remains: what is the maximal speed of the car for the Arduino not to skip pulses? Is it possible to calculate that?

from atlascar2.

Sarxell avatar Sarxell commented on July 28, 2024

Hi!

It "is" possible!

Checking the atlascar2's specifications it says the max speed of the car is 130km/h

130 km/h -> 36.1 m/s
We can check the number of turns the wheel gives using its perimeter.
With a radius of 0.285 m -> 2pir = 1.79 m

36.1/1.79 = 20.16 turns per second

Since the encoder as 1000 ppr -> 1000 * 20.16 = 20160 pulses per second

BUT, checking the code we have two interrupts both on change! which means x4 that value for interrupts:
80 640 interrupts/second ... So we need a little more than 80 kHz if I'm thinking right but I can be mistaken.

This seems small since the Arduino says that it provides 16/20 MHz ... But it doesn't.
If we are not using it sure but each instruction decreases this value by a lot. A realistic value by the forums is 275 kHz if the Arduino only interrupts or does a small program ...So in reality I don't know since it depends on the code... we could test this on the road but without the electric panel we can only drive inside DEM at low speeds...

from atlascar2.

vitoruapt avatar vitoruapt commented on July 28, 2024

OK. It seems reasonable, however I do not understand why you have interrupts on both the rising and falling edges of the pulse. Wouldn't it be enough to have only in one of them? Concerning maximal interrupt rates in Arduino, you can check some more tentative realistic calculations at https://forum.arduino.cc/t/max-interrupts-second/357256/8.
With the increase of speed of the car, less time may be left available in the Arduino to dispatch the message to the CAN bus. So, perhaps, that's one more reason to include the Arduino time stamp in the CAN message along with the encoder value.

from atlascar2.

manuelgitgomes avatar manuelgitgomes commented on July 28, 2024

Solved

from atlascar2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.