B0 Communcation with Coppelia
Posted: 01 Sep 2020, 07:35
Hello,
I tried to use B0Demo Scene and write a publisher using B0 in c++, they communicate but the unpacking in coppelia side is not correct as I send number bigger than zero from c++ B0 publisher but receive at coppelia after unpacking the same number 6.3372196379419e-10. Check the code used below. Can you please advise me?
C++ code:
static float i = 0;
std::string msg = std::to_string(i++);
pub.publish(msg);
Lua coppelia side:
function number_callback(msg)
local number=sim.unpackFloatTable(msg)[1]
end
sub_number=simB0.subscriberCreate(b0Node,numberTopicNumber,'number_callback')
simB0.subscriberDestroy(sub_number)
I tried to use B0Demo Scene and write a publisher using B0 in c++, they communicate but the unpacking in coppelia side is not correct as I send number bigger than zero from c++ B0 publisher but receive at coppelia after unpacking the same number 6.3372196379419e-10. Check the code used below. Can you please advise me?
C++ code:
static float i = 0;
std::string msg = std::to_string(i++);
pub.publish(msg);
Lua coppelia side:
function number_callback(msg)
local number=sim.unpackFloatTable(msg)[1]
end
sub_number=simB0.subscriberCreate(b0Node,numberTopicNumber,'number_callback')
simB0.subscriberDestroy(sub_number)