Unit 4 Part 1 Project

Good morning, I´m having some problems with the python code that has to move the robot. It seems that the laser values could be different than the posted. I think i coded “well” the logic for the exercise but is not working 100% as it should. I´m posting the code, so if you could give me an advice to improve or where i should look to improve the exercise i will appreciate it. If I stay too much time here, should I pass and comeback later while i continue with the course? Keep in mind i´m a beginner in robotics and ros too.

Well i don’t really know what the problem is but at the moment it seems like the robot should not move at all since the function where the movement is defined is not called

Hi. I guess you are working on 4.3 Topics Quiz. I’m not sure what you are trying from the code only.
But, If I follow the instruction;
(1)The third condition “elif ranges[0]>0.3” should be something like “elif ranges[719]<0.2” to check laser reading on left side, not right side. When the node starts, your condition is true since you don’t have a wall on right side.
(2)Also, the instruction says topic is “/kobuki/laser/scan” not “/scan”.

I hope you will find this helpful.

Each time that we have new info in /scan it will execute the read_data function as i coded in the constructor function of the class. The robot is moving, but the problem is that is not moving as it should to do the good path. The enviroment is like a box and you have to do like a square but with some restrictions that in the code i think are resolved but when I launch the robot seems is not doing the path it should or i think it should with the code that I make.

I´m not, I´m working in the project that starts when you finish the 4.3 Quiz. You will see that for the project the topic will be /scan and the simulation is in a different environment, it´s not the wall.
I appreciate your help

Hi @pepemarques01.
I think the topic “/scan” gives you 360 degree data, unlike /kobuki/laser/scan of 4.3 Topics Quiz which is 180deg. So, try ranges[180] as the reading of right side.

seems it gives 720 ranges as when I try to print range[719] was printing it.

I mean “/scan” gives you distance of full circle, whereas “/kobuki/laser/scan” gives only half circle of front side. So the ranges[0] (≒ranges[719]) of “/scan” is back side of robot.

oh ok, now i understand it. Ty so much.

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