简体   繁体   中英

Rotation in certain direction in webots

i need help in understanding rotation values in webots. How do I calculate and set them? I want my robot to rotate in direction of the certain object.

For example, if the ball is rolling around the robot, the robot tries to get the position of the ball and rotate to it, so that the robot is always facing the ball.

Does anybody have an idea how can I do it?

My thoughts on coding it:

  1. Get position of the ball
  2. Get position of the robot
  3. Calculate the angle between them
  4. Rotate the robot by calculated angle

Thanks in advance!

You don't have to calculate the angle, it is enough to find the position of the ball in a 2D image plane. If the ball is left from the image center the robot should rotate left and if the ball is right from the image center the robot should rotate right.

You can find an example here:
https://github.com/lukicdarkoo/webots-example-visual-tracking

and you can see the result here:
https://lukicdarkoo.github.io/webots-example-visual-tracking/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM