Ros发布者在保存后不与V-Rep合作

时间:2014-08-11 22:48:28

标签: simulation ros publisher

我开始使用V-Rep来模拟一些机器人(最初是Pioneers和quadrotors),但是当我尝试将它与ROS连接时,我一直遇到问题。我尝试从RosTopicPublisherAndSubscriber.ttt复制示例,它只在第一次工作,在我关闭它并再次加载后,它不再工作了,我的代码实际上与示例相同,只是我使用了getPose并且它是先锋(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标签,那就太棒了!

1 个答案:

答案 0 :(得分: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,'')