python differential drive robot simulation [ part 2 ]: implementation

preview_player
Показать описание
in this step-by-step tutorial, we will simulate and visualize a differential drive robot in python from scratch.
first, we explained some of the implementation details in the introductory video, and in this video we are writing the actual code and test the project.

the content :
0:00 intro
0:30 code structure
1:02 initializing the environment class and the animation loop
2:48 initializing the robot class
4:31 robot draw method (Robot class )
4:36 robot move method (Robot class )
9:25 write info method ( environment class)
11:00 trail method ( environment class)
12:22 robot reference frame ( environment class)
14:06 debugging
15:18 future work
15:35 :outro

hashtags:
#python #pythonprojects #robotics #selfdrive
Рекомендации по теме
Комментарии
Автор

welcome to the comments section, feel free to ask questions and suggest ideas .

hobby_coding
Автор

Just a quick addition:

Theta is calculated as: (vr-vl)/L, where L is the distance between the wheels of the robot, not the width of the robot as mentioned in the video

goplayman
Автор

That was an amazing explanation. Im new to python and to english language, and still you made me understand. Thank you!!

cauancarvalhomarotta
Автор

A very good tutorial to understand the mobile robots, thank you very much for your effort

batuhanatasoy
Автор

Can you make 3 differential robots, one is leader, second one and third one follow the leader by distance-distance control and distance-angle control? It is how desai suggested.

meralkilicarslan
Автор

which software you are using to write the code
if possible can you post the link of the softwarre

SaurabhKumar-cbms
Автор

In my simulation, trail is not moving, it stays as a line, it doesn't go when the robot goes. Why?

def trail(self, pos):
for i in range(0, len(self.trail_set)-1):
pygame.draw.line(self.map, self.yel, (self.trail_set[i][0], self.trail_set[i][1]), (
self.trail_set[i+1][0], self.trail_set[i+1][1]))
if self.trail_set.__sizeof__() > 30000:
self.trail_set.pop(0)
self.trail_set.append(pos)

def robot_frame(self, pos, rotation):
n = 80

centerx, centery = pos
x_axis = (centerx + n * math.cos(-rotation),
centery + n * math.sin(-rotation))
y_axis = (centerx + n * math.cos(-rotation + math.pi/2),
centery + n * math.sin(-rotation + math.pi/2))
pygame.draw.line(self.map, self.red, (centerx, centery), x_axis, 3)
pygame.draw.line(self.map, self.green, (centerx, centery), y_axis, 3)

meralkilicarslan
Автор

In my simulation, robaot trail is not moving with the robot. Why?

def trail(self, pos):
for i in range(0, len(self.trail_set)-1):
pygame.draw.line(self.map, self.yel, (self.trail_set[i][0], self.trail_set[i][1]), (
self.trail_set[i+1][0], self.trail_set[i+1][1]))
if self.trail_set.__sizeof__() > 30000:
self.trail_set.pop(0)
self.trail_set.append(pos)

def robot_frame(self, pos, rotation):
n = 80

centerx, centery = pos
x_axis = (centerx + n * math.cos(-rotation),
centery + n * math.sin(-rotation))
y_axis = (centerx + n * math.cos(-rotation + math.pi/2),
centery + n * math.sin(-rotation + math.pi/2))
pygame.draw.line(self.map, self.red, (centerx, centery), x_axis, 3)
pygame.draw.line(self.map, self.green, (centerx, centery), y_axis, 3)

meralkilicarslan
Автор

can u do the same project using a robot like real one

chiragbangera
Автор

Please wich lignes of the code that make the robot rotate

saoussanmoustaoui
Автор

Thank you for this video it is very helpful also, could you please share the source code :)
thanks in advance

moatazkhaled