ARIA-Users

Date Index Thread Index

Re: [Aria-users] Send commands to server robot to let it move andturn



The commands for ArNetworking are NOT the same as the microcontroller 
commands you send from ArRobot.  What you are trying to do won't work 
the way you are trying it.  ArNetworking works at a higher level.  The 
packets go into code that then does something with them.

Also you should never use requestOnceByCommand, it isn't for doing what 
you are trying, but is internal and the command numbers change depending 
on the run (again, these aren't the same as the microcontroller command 
numbers).

You can look at examples/serverDemo.cpp, examples/clientDemo.cpp, 
tests/standAloneServer.cpp and tests/standAloneClient.cpp to see some of 
the ways that ArNetworking works with commands.

Matt LaFary
MobileRobots Inc


wjxnet_126 wrote:
>  hello, everyone!
>  
> I have two robots, one is server, the other is acted as client. The client sends some commands to the server, to let the 
>  
> server robot move and turn, the following is my codes:
>  
> int main(int argc, char **argv)
> {
>    Aria::init();
>   
>   ArArgumentParser parser(&argc, argv);
>   parser.loadDefaultArguments();
>     if (!Aria::parseArgs() || !parser.checkHelpAndWarnUnparsed())
>   {
>     Aria::logOptions();
>     exit(0);
>   }
>     ArClientBase client;
>   
>   ArClientSimpleConnector clientConnector(&parser);
>   
>   if (!clientConnector.connectClient(&client))
>   {
>     if (client.wasRejected())
>       printf("Server '%s' rejected connection, exiting\n", client.getHost());
>     else
>       printf("Could not connect to server '%s', exiting\n", client.getHost());
>     exit(1);
>   } 
>  
>   client.runAsync();
>   
>   double myTurnValue=30,myMoveValue=3000;
>   ///attention please
>   ArNetPacket packet;
>   packet.doubleToBuf(myTurnValue);
>   printf("Telling the server to turn \n");
>   client.requestOnceByCommand(12, &packet); // heading 
>   
>   packet.doubleToBuf(myMoveValue);
>   printf("Telling the server to move \n");
>   client.requestOnceByCommand(8, &packet); // move
>  
>  Aria::shutdown();
>   return 0;
> }
>  
>  Could you please take a look at it, since the server just does not do the action. Thanks!
>  
>  
> Jianxin Wu