Hi! I have to hand this coursework in tomorrow, slight snag in the mapping part of it. I'm moving from "robot view" to "display view". Basically the robot is drawing a map of the screen based on what it picks up on radar -
pseudocoding it because my Uni uses turn it in:
robot x = get robot's x position
robot y = get robot's y position
robot t = get robot's theta (angle relative to the room)
distance = get sonar distance from sonar at 10 degrees
Get the x and y of the picked up object relative to the robot.
x = cos(10) * distance
y = sin(10) * distance
Relative to the bot, there is an object at (x,y)
Convert to the display coordinate system
display x = (cos(-t) * x) - (sin(-t) * y)
display y = (sin(-t) * x) + (cos(-t) * y)
Basically have rotated it around (0,0) -t degrees
Translate based on the robot's position
display x -= robot x
display y -= robot y
add point to map: (display x, display y)
____________________________________
My question is simply: is the above correct? Should it work?
It's not working, I'm getting garbage, but I need to acertain whether it's my coding or the robot itself that is broken.
Thanks in advance.
pseudocoding it because my Uni uses turn it in:
robot x = get robot's x position
robot y = get robot's y position
robot t = get robot's theta (angle relative to the room)
distance = get sonar distance from sonar at 10 degrees
Get the x and y of the picked up object relative to the robot.
x = cos(10) * distance
y = sin(10) * distance
Relative to the bot, there is an object at (x,y)
Convert to the display coordinate system
display x = (cos(-t) * x) - (sin(-t) * y)
display y = (sin(-t) * x) + (cos(-t) * y)
Basically have rotated it around (0,0) -t degrees
Translate based on the robot's position
display x -= robot x
display y -= robot y
add point to map: (display x, display y)
____________________________________
My question is simply: is the above correct? Should it work?
It's not working, I'm getting garbage, but I need to acertain whether it's my coding or the robot itself that is broken.
Thanks in advance.