ros client not working
Posted: 22 Mar 2022, 18:29
I'm using a custom ros service data:
I'm able to make server work perfectly fine (tested with terminal):
But problem client is not working. As soon as I hit play entire simulation just get stuck
As soon as I hit play entire simulation just get stuck. after I do ctrl+c everything stop and I get error in the terminal.
Thanks in advance !!!
Code: Select all
rossrv show beginner_tutorials/AddTwoInts
int64 a
int64 b
---
int64 sum
Code: Select all
function sysCall_init()
-- do some initialization here
sev = simROS.advertiseService('/add_server', 'beginner_tutorials/AddTwoInts', 'add_number')
end
function sysCall_cleanup()
-- do some clean-up here
simROS.shutdownServiceServer(sev)
end
function add_number(req)
ans = req.a + req.b
print(ans)
p={sum=ans}
return p
end
But problem client is not working. As soon as I hit play entire simulation just get stuck
Code: Select all
function sysCall_init()
-- do some initialization here
client = simROS.serviceClient('/add_server', 'beginner_tutorials/AddTwoInts')
print(client)
if client then
values = {a=1,b=5}
result=simROS.call(client, values)
end
end
I'm not sure how to write the "values" in simROS.call(). Let me know what is the write way to make ros client.7: failed to call service beginner_tutorials/AddTwoInts (in function 'simROS.call@simExtROS')
stack traceback:
[C]: in function 'simROS.call'
[string "Dummy@childScript"]:7: in function 'sysCall_init'
[Dummy@childScript:error] 22: non-existent object handle (in function 'simROS.shutdownServiceServer@simExtROS')
stack traceback:
[C]: in function 'simROS.shutdownServiceServer'
[string "Dummy@childScript"]:22: in function 'sysCall_cleanup'
Thanks in advance !!!