followPath ROS service

Typically: "How do I... ", "How can I... " questions
Post Reply
formica
Posts: 52
Joined: 13 Mar 2013, 12:13

followPath ROS service

Post by formica » 10 Sep 2016, 00:23

Dear coppelia,
my goal is implementing a ROS service, called 'followPath' to follow a precomputed path.
This is the code, contained in a threaded child script, that I call using simRosCallScriptFunction:

Code: Select all

followPath=function()	
	while simGetSimulationState()~=sim_simulation_advancing_abouttostop do
	targetObj=simGetObjectHandle('Quadricopter_target')
        pathObj=simGetObjectHandle('Path') 
        scriptHandle=simGetScriptHandle('Quadricopter_base')
        speed=simGetScriptSimulationParameter(scriptHandle,'speed',false)
        acceleration=simGetScriptSimulationParameter(scriptHandle,'acceleration',false)
        simFollowPath(targetObj,pathObj,3,0.1,speed,acceleration)
	end
end
... but apparently nothing happens.
Do you have any hint?

Regards
Roberto

coppelia
Site Admin
Posts: 7396
Joined: 14 Dec 2012, 00:25

Re: followPath ROS service

Post by coppelia » 12 Sep 2016, 07:48

Hello Roberto,

the best would be to use the new Ros interface, which is much more flexible, extendable and naturally duplicates the ROS C++ API.
But with the old Ros plugin, you should have your function defined as follows:

Code: Select all

followPath=function(inInts,inFloats,inStrings,inBuffer)
    ...
    local outInts={}
    local outFloats={}
    local outStrings={}
    local outBuffer=''
    return outInts,outFloats,outStrings,outBuffer
end
Cheers

Post Reply