Odometry.py code problem

i get the above error when i try to run the odometry.py python code, i understand its cus dt is zero but im not able to figure out why dt is zero and every variable used to determine dt also ends up being zero. please help.
Regards.

Hi @viswadeepkopalli2000, coul you show your whole script or share the rosject so we can have a better look of whats happening?
for now you can try and catch ZeroDivisionError to avoid your script breaking




that is the code, its the same code given in the chapter 2 of kinematics of mobile robot course.

were you able to find any mistake in the code ? i tried debugging it but i got no result.

hi @viswadeepkopalli2000 sorry for the late response, i see no errors here. if you want, send me the whole package so i can test it locally and have a better look to it, here is my mail:
u1802520@unimilitar.edu.co

sent the mail and thank you in advance :smile: .

Hi @viswadeepkopalli2000, i recieved the package but i could no test it because i need the dependencies packages, seems that you have an encoder msg and a /encoder publisher somwhere.
i made some test though, with rospy.Time but even with tiny differences of time there is no way dt should be 0. this need more help that i can give, look at this:


this is the output when i run gazebo_ros empty world. the difference you are evaluating is 0.0
but if i just run the script with roscore, this is the output:

seems that is something about how gazebo manage the time (sim time).
i honestly don’t know why this happen. I suggest to contact a staff member, they might know better.

thank you very much, ill try to contact the staff members, if you dont mind me asking i see you are using visual studio as an ide for ROS can you shed some light on how you did it ? or any website you can point me too ? would appreciate it if you could, thank you in advance.

it is Vscode with some extensions like URDF and ROS also i created some snippets myself.

I’ll have a look into this and come back to you. Thanks for the data.

Hello,

I’ve just updated the odometry code in the notebook. While testing I noticed that sometimes it is still failing with this error so I couldn’t fix it 100%. I haven’t figured out yet why it’s still failing sometimes. If you get this error, just rerun the code and it will work.

hi, i tried the code and it works now, thank you very much, and what was causing the problem?
thank you.