如何在 Breve Simulator 中为机器人添加摄像头?

发布于 2024-07-24 16:44:52 字数 166 浏览 6 评论 0原文

我创建了一个基于布雷滕伯格车辆的两轮机器人。 我们的机器人有两个轮子和一个 PolygonDisk 主体(很像 kepera 和 e-puck 机器人)。 我想在机器人的前面添加一个摄像头。 那么问题就变成了如何控制相机以及如何保持将其指向正确的方向(与机器人相同的方向)。 如何使相机指向与机器人相同的方向?

I've created a two wheeled robot based on the braitenberg vehicle. Our robots have two wheels and a PolygonDisk body(Much like kepera and e-puck robots). I would like to add a camera to the front of the robot. The problem then becomes how to control the camera and how to keep pointing it in the right direction(same direction as the robot). How can you make the camera point in the same direction as the robot ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

余生再见 2024-07-31 16:44:52

经过多次尝试和失败,我终于成功了。
所以我是这样做的:

总体思路是有一个链接或对象链接到车辆,然后测量
它的旋转和位置,以便找出相机应瞄准的方向。

1) 添加链接到机器人的对象:

def addVisualCam(self):
    joint = None
    cam = breve.createInstances(breve.Link,1)
    cam.setShape(breve.createInstances(breve.PolygonCone, 1).initWith(10,0.08,0.08))
    joint = breve.createInstances(breve.FixedJoint,1)
    # So ad-hoc it hurts. oh well...
    joint.setRelativeRotation(breve.vector(0,1,0), -3.14/2)
    joint.link(breve.vector(0,1.05,0), breve.vector(0,0,0), cam, self.vehicle.bodyLink, 0)
    joint.setDoubleSpring(300, 1.01000, -1.01000)
    self.vehicle.addDependency(joint)
    self.vehicle.addDependency(cam)
    cam.setColor(breve.vector(0,0,0))
    self.cam = cam

2) 添加此 postIterate:

def postIterate(self):
    look_at = self.cam.getLocation() + (self.cam.getRotation() * breve.vector(0,0,1))
    look_from = -(self.cam.getRotation()*breve.vector(0,0,1))
    self.vision.look(look_at, look_from)

After much trying and failing I finally made it work.
So here is how I did it:

The general idea is to have an link or object linked to the vehicle and then measuring
its rotation and location in order to find out in which direction the camera should be aimed.

1) Add an object that is linked to the robot:

def addVisualCam(self):
    joint = None
    cam = breve.createInstances(breve.Link,1)
    cam.setShape(breve.createInstances(breve.PolygonCone, 1).initWith(10,0.08,0.08))
    joint = breve.createInstances(breve.FixedJoint,1)
    # So ad-hoc it hurts. oh well...
    joint.setRelativeRotation(breve.vector(0,1,0), -3.14/2)
    joint.link(breve.vector(0,1.05,0), breve.vector(0,0,0), cam, self.vehicle.bodyLink, 0)
    joint.setDoubleSpring(300, 1.01000, -1.01000)
    self.vehicle.addDependency(joint)
    self.vehicle.addDependency(cam)
    cam.setColor(breve.vector(0,0,0))
    self.cam = cam

2) Add this postIterate:

def postIterate(self):
    look_at = self.cam.getLocation() + (self.cam.getRotation() * breve.vector(0,0,1))
    look_from = -(self.cam.getRotation()*breve.vector(0,0,1))
    self.vision.look(look_at, look_from)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文