From: Toby C. <tco...@pl...> - 2006-10-20 20:59:20
|
The relay driver is very simple, any command it receives it will output as data to all subscribed clients. The best way to test it is to create a server with a single relay driver >> driver( >> name "relay" >> provides ["6665:opaque:0"] >> ) and then two player clients that subscribe to it, one that sends commands and the other that outputs its received data to console. I think that you dont want the relay driver, if you want to be able to control what is sent from within a driver you will need a custom driver that supports the opaque interface. The relay driver is controlled by clients that have subscribed to it. Toby P.S. please send everything via the mailing lists even if it seems a simple question or is directed to a specific developer then it all gets archived. ra...@gm... wrote: > Hey Toby, > > Is there a simple example somewhere that would show how the relay driver works - basically two robots sending each one's name to the other robot. There are bits and pieces of information everywhere, but no source is complete. > > I have tried all permutations and combinations with relay and opaque, and they don't seem to work. Is the source for relay checked in somewhere? > > Thanks a lot, > > Ram > > Toby Collett-3 wrote: >> Can you post all messages to the mailing list, this way they get >> archived and other can help as well. >> >> stage doesnt support the opaque proxy directly so you will need to >> instantiate a relay driver for each of the two robots, i.e. >> >> driver( >> name "relay" >> provides ["6665:opaque:0"] >> ) >> >> driver( >> name "relay" >> provides ["6666:opaque:0"] >> ) >> >> and remove the requires lines from the stage entries... >> >> Toby >> >> Yashan Sun wrote: >>> Hey Toby, >>> >>> My .cfg is, >>> driver >>> ( name "stage" >>> provides ["simulation:0" ] >>> plugin "libstageplugin" >>> worldfile "simple_ys.world" ) >>> >>> driver >>> ( >>> name "stage" >>> provides ["6665:position2d:0" "6665:laser:0"] >>> requires ["6665:opaque:0"] >>> model "robot1" >>> ) >>> >>> driver( >>> name "stage" >>> provides ["6666:position2d:0" "6666:laser:0"] >>> requires ["6666:opaque:0" ] >>> model "robot2" >>> ) >>> >>> driver( >>> name "relay" >>> provides ["opaque:0"] >>> # provides ["6665:opaque:0" "6666:opaque:0"] >>> ) >>> >>> My. cpp file is, >>> #include <libplayerc++/playerc++.h> >>> #include <libplayerc/playerc.h> >>> #include <iostream> >>> #include "args.h" >>> >>> >>> int >>> main(int argc, char **argv) >>> { >>> parse_args(argc,argv); >>> >>> try >>> { >>> using namespace PlayerCc; >>> >>> PlayerClient robot(gHostname, gPort); >>> Position2dProxy pp(&robot, gIndex); >>> LaserProxy lp(&robot, gIndex); >>> OpaqueProxy op(&robot, gIndex); >>> >>> player_opaque_data_t opData; >>> uint8_t opGetData[PLAYER_OPAQUE_MAX_SIZE]; >>> PlayerClient robot1(gHostname, 6666); >>> Position2dProxy pp1(&robot1, gIndex); >>> LaserProxy lp1(&robot1, gIndex); >>> // OpaqueProxy op1(&robot1, 0); (*****) >>> player_opaque_data_t op1Data; >>> uint8_t op1GetData[PLAYER_OPAQUE_MAX_SIZE ]; >>> >>> for(;;) >>> { >>> robot.Read(); >>> >>> opData.data_count = 3; >>> opData.data[0]='a'; >>> opData.data[1]='b'; >>> opData.data[2]='c'; >>> op.SendCmd(&opData); >>> std::cout << opData.data << std::endl; >>> uint count = op.GetCount(); >>> std::cout << "count=" << count << std::endl; >>> op.GetData(opGetData); >>> std::cout << "opGetData[0]=" << opGetData[0] << std::endl; >>> std::cout << "opGetData[1]=" <<opGetData[1] << std::endl; >>> std::cout << "opGetData[2]=" <<opGetData[2] << std::endl; >>> std::cout << "opGetData[3]=" <<opGetData[3] << std::endl; >>> } >>> } >>> catch (PlayerCc::PlayerError e) >>> { >>> std::cerr << e << std::endl; >>> return -1; >>> } >>> } >>> >>> *the output for "player mycfg. cfg":* >>> Stage driver creating 2 devices >>> 6665.4.0 is "robot1" >>> 6665.6.0 is "robot1.laser:0" >>> Stage driver creating 2 devices >>> 6666.4.0 is "robot2" >>> 6666.6.0 is "robot2.laser:0" >>> simple_ys.cfg:27 warning: field [requires] is defined but not used >>> simple_ys.cfg:34 warning: field [requires] is defined but not used >>> Listening on ports: 6665 6666 >>> accepted client 0 on port 6665, fd 11 >>> accepted client 1 on port 6666, fd 12 >>> warn: Stage ignores motor power state (1) (p_position.cc ProcessMessage) >>> interface 57 51 >>> type 3 1 >>> subtype 3 2 >>> warning : skipping message from 51:0 with unsupported type 1:2 >>> interface 57 51 >>> type 3 1 >>> subtype 3 2 >>> warning : skipping message from 51:0 with unsupported type 1:2 >>> >>> what is the meaning of type or subtype? >>> * >>> the output for "./mycc": >>> *abc >>> count=0 >>> opGetData[0]= >>> opGetData[1]=4 >>> opGetData[2]= >>> opGetData[3]=@ >>> * >>> *It seems that i cannot GetData from opaque device. The data_count is >>> equal to zero. >>> How can I fix the problem? >>> >>> >>> When I uncomment the line "// OpaqueProxy op1(&robot1, 0); >>> (*****)", >>> I can compile mycc file correctly. But when I run "./mycc" >>> I get, >>> playerc error : got NACK from request >>> playerc error : failed to get response >>> OpaqueProxy::OpaqueProxy()(-1) : could not subscribe >>> >>> Does it mean that i cannot claim to two opaqueproxies in a one file? >>> If so, how can i realize the client-2-client communication. >>> >>> I do appreciate your kindly help ... : ) >>> >>> Best, >>> yashan >>> >> >> ------------------------------------------------------------------------- >> Using Tomcat but need to do more? Need to support web services, security? >> Get stuff done quickly with pre-integrated technology to make your job >> easier >> Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo >> http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 >> _______________________________________________ >> Playerstage-users mailing list >> Pla...@li... >> https://lists.sourceforge.net/lists/listinfo/playerstage-users >> >> > Quoted from: > http://www.nabble.com/Re%3A-need-help-on-opaque-tf1934991.html#a5301810 > |