From: kingwinter <kin...@gm...> - 2010-06-18 00:45:59
|
I am trying to let robot1 to write data to blackboard and use robot2 to read data in every 1s. The robot1 player client code is: >>>>robot1f.cpp>>>>>>>> #include <libplayerc++/playerc++.h> #include <iostream> #include "args.h" #define KEY "SSL" #define GROUP "JD" using namespace std; int main(int argc, char **argv) { using namespace PlayerCc; const char * key = strdup(KEY);; const char * group = strdup(GROUP); PlayerClient robot ("localhost", 6665); BlackBoardProxy bb (&robot, 0); bb.SubscribeToKey(key, group); player_blackboard_entry_t *entry = new player_blackboard_entry_t; memset(entry, 0, sizeof(entry)); entry->key = strdup(KEY); entry->key_count = strlen(KEY) + 1; entry->data = new uint8_t[4]; entry->data[0] = 4; entry->data[1] = 3; entry->data[2] = 2; entry->data[3] = 1; entry->data_count = 4; while(1) { bb.SetEntry(*entry); sleep(1); } } >>>>>>>>>>>>>>>>>>> and robot2.cpp are following code >>>>>>>>>>>>> #include <libplayerc++/playerc++.h> #include <iostream> #include "args.h" #define KEY "SSL" #define GROUP "JD" using namespace std; void On_First_Device_Event(playerc_blackboard_t *blackboard, player_blackboard_entry_t event) { printf("First device event fired for key '%s'\n", event.key); printf("Key value = %d,%d,%d,%d\n", event.data[0], event.data[1], event.data[2], event.data[3]); } int main(int argc, char **argv) { using namespace PlayerCc; const char * key = strdup(KEY);; const char * group = strdup(GROUP); PlayerClient robot ("localhost", 6665); BlackBoardProxy bb (&robot, 0); bb.SubscribeToKey(key, group); player_blackboard_entry_t *entry; bb.SetEventHandler(On_First_Device_Event); while(1) { //robot.Read(); entry = bb.GetEntry(KEY,GROUP); cerr<<"datacount"<<entry->data_count<<endl; sleep(1); } } >>>>>>>>>>>>>the player server cfg file is driver ( name "localbb" provides [ "blackboard:0" ] ) >>>>>>>>>>>>>>>>>> I start to run player server and then run robot1 first. Then I start the robot2. It looks it cannot get the entry written by robot1. It output the "datacount0" rather than expected "datacount4". If I uncomment the line of "robot.Read()", then program stuck there and cannot return from read(). Any idea about the problem? Shall I acknowledge player when I setentry in robot1? Thanks Kingwinter -- View this message in context: http://old.nabble.com/problem-with-Blackboard-tp28921251p28921251.html Sent from the playerstage-users mailing list archive at Nabble.com. |