From: Toby C. <tco...@pl...> - 2008-01-10 02:06:17
|
The opaque data structure does not automatically allocate space to store the data in. player_opaque_data_t Odata; you need to allocate this space before you call GetData. Toby On 10/01/2008, Yee Chui Ching <ych...@ya...> wrote: > > driver > ( > name "stage" > provides ["6665:position2d:0" "6665:laser:0" > "6665:fiducial:0" ] > model "robot1" > ) > > driver > ( > name "relay" > provides ["6665:opaque:0"] > ) > > > driver > ( > name "stage" > provides ["6666:position2d:0" "6666:laser:0" > "6666:fiducial:0" ] > model "robot2" > ) > > Is this the way to configure .cfg file to make robot2 > become client and robot1 become server? > > > For client program: > > typedef struct > { > int id; > } num_t; > > int main(int argc, char** argv) > { > PlayerClient robot(gHostname, gPort); > > if ( robot.GetPort() != 6665) > { > PlayerClient robot1 ("localhost", 6665); > op1 = new OpaqueProxy (&robot1, 0); > } > > if ( robot.GetPort() == 6665) > op = new OpaqueProxy (&robot, 0); > > num_t* Onum; > player_opaque_data_t Odata; > Onum = reinterpret_cast<num_t*>(Odata.data); > > robot.Read(); > > if ( robot.GetPort() == 6665) > { > Onum->id = 1; > op->SendCmd(&Odata); // send data > } > > else if ( robot.GetPort() == 6666) > { > for (int g=0; g<50;g++) > { > robot.Read(); > op1->GetData(Odata.data); > cout << Onum->id <<endl; > } > } > } > > I run both robot1 and robot2 using the same code > above, it get error for robot2 : Segmentation fault > (core dumped). > > Then, i delete "op1->GetData(Odata.data);" , robot2 > can run but cannot receive data sent by robot1, > results got form robot2 is all "0"s instead "1". > > Is it robot2 can get data without using opaque member > function? how it do that? or i missing some important > communication linkage between these 2 robots? > > Thanks lots... > > > Send instant messages to your online friends http://uk.messenger.yahoo.com > > ------------------------------------------------------------------------- > Check out the new SourceForge.net Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > Playerstage-users mailing list > Pla...@li... > https://lists.sourceforge.net/lists/listinfo/playerstage-users > -- This email is intended for the addressee only and may contain privileged and/or confidential information |