从代码中添加和删除机器人/车辆,而不是在wbt文件中指定

2024-04-28 18:11:54 发布

您现在位置:Python中文网/ 问答频道 /正文

使用/usr/local/webots/projects/default/controllers中的sumo_supervisor示例,我能够使用traci控制器在webots模拟中生成和删除车辆(bmwx)。 但是,当我尝试使用Objects.py文件中的以下修改将ros_automobile指定为我的控制器而不是sumo时

defName = "EGO_VEHICLE%d" % index
    vehicleString = "DEF " + defName + " " + model + " {\n"
    #vehicleString += "  translation 10000 0.5 0\n"
    vehicleString += "  translation -3.16697 0.317 -173.705\n"
    vehicleString += "  controller \"ros_automobile\"\n"
    vehicleString += "  sensorsSlotCenter [\n"
    vehicleString += "    GPS {\n"
    vehicleString += "    }\n"
    vehicleString += "   ]\n"

我得到以下错误([ros_automobile]错误:只有基于“Car”节点的节点才能使用Car库。) enter image description here

我将非常感谢你们提供的任何指导。谢谢你抽出时间


Tags: default节点usrlocal错误ros控制器car
1条回答
网友
1楼 · 发布于 2024-04-28 18:11:54

相扑监督员正在使用简化版的赛车,而不是通常的赛车,这是为了使模拟运行更平稳:https://cyberbotics.com/doc/automobile/car#simple-vehicles

与其修改sumo控制器,不如在模拟中添加具有正确控制器的车辆,并设置适当的DEF名称,以便sumo主管在需要时使用:https://cyberbotics.com/doc/automobile/sumo-interface#use-vehicles-already-present-in-the-world

如果您只想插入和移除车辆,而不想使用SUMO界面,从控制器添加机器人,非常简单,您只需使用supervisor API: -https://cyberbotics.com/doc/guide/supervisor-programming -https://cyberbotics.com/doc/reference/supervisor 特别是,这些函数可用于导入新节点: https://cyberbotics.com/doc/reference/supervisor#wb_supervisor_field_import_mf_node

相关问题 更多 >