1

我已经开始使用 V-Rep 来模拟一些机器人(最初是 Pioneers 和 quadrotor),但是当我尝试将它与 ROS 连接时遇到了问题。我试图从 RosTopicPublisherAndSubscriber.ttt 复制示例,它只在第一次工作,在我关闭它并再次加载后,它不再工作,我的代码实际上与示例相同,除了我使用 getPose 并且它是一个 Pioneer(V-Rep 附带的那个),这是我的代码:

if (simGetScriptExecutionCount()==0) then

    -- Check if the required plugin is there (libv_repExtRos.so or libv_repExtRos.dylib):
    local moduleName=0
    local moduleVersion=0
    local index=0
    local pluginNotFound=true
    while moduleName do
        moduleName,moduleVersion=simGetModuleName(index)
        if (moduleName=='Ros') then
            pluginNotFound=false
        end
        index=index+1
    end

    if (pluginNotFound) then

        simDisplayDialog('Error','ROS plugin was not found.&&nSimulation will not run properly',sim_dlgstyle_ok,false,nil,{0.8,0,0,0,0,0},{0.5,0,0,1,1,1})
    else

        -- Retrive the handle of the vision sensor we wish to stream:
        lHandle=simGetObjectHandle('Pioneer_p3dx')

        -- Now enable topic publishing and streaming of the vision sensor's data:
        topicName=simExtROS_enablePublisher('p3dx',1,simros_strmcmd_get_object_pose,lHandle,0,'')
        if (topicName == nil) then
            simDisplayDialog('Error','Nil',sim_dlgstyle_ok,false,nil,{0.8,0,0,0,0,0},{0.5,0,0,1,1,1})
        else
            simDisplayDialog('Error','Not Nil',sim_dlgstyle_ok,false,nil,{0.8,0,0,0,0,0},{0.5,0,0,1,1,1})
        end
        -- Retrive the handle of the passive vision sensor. We will use the passive vision sensor

    end
end

欢迎任何想法!提前致谢!PS:另外,如果有 1500 声望点的人可以创建 v-rep 标签,那就太好了!

4

1 回答 1

1

好的,V-REP 的人帮我解决了这个问题。所以基本上我应该使用参数作为 -1 而不是 0。

所以基本上,一个应该这样做

topicName=simExtROS_enablePublisher('p3dx',1,simros_strmcmd_get_object_pose,lHandle,-1,'')

代替

topicName=simExtROS_enablePublisher('p3dx',1,simros_strmcmd_get_object_pose,lHandle,0,'')
于 2014-10-08T19:10:12.953 回答