00001
00110 carmen_ipc_initialize(argc, argv);
00111 carmen_param_check_version(argv[0]);
00112
00113
00114
00115 carmen_simulator_connect_robots("localhost:1382");
00116
00117
00118
00119
00120 IPC_connectModule(argv[0], "localhost:1382");
00121
00122
00123
00124 carmen_simulator_connect_robots("localhost");
00125
00126 return 0;
00127 }
00128 @endverbatim
00129
00130
00131 Position the first robot (using the first \c navigator_panel). Position
00132 the second robot (using the second \c navigator_panel) so that it is a
00133 little bit in front of where you put the first robot (which of course you
00134 can't see in the second \c navigator_panel) and pointing back at the first
00135 robot. If you start two instances of \c robotgraph, you should see the
00136 other robot in each robotgraph. As you drive the robots around, they should
00137 interfere with each other and see each other, just as if they were physically
00138 there.
00139
00140 @section faq_f How can I control multiple robots in a multi-robot simulation?
00141
00142 The first thing is to get both simulations working, as described above.
00143
00144 The next thing is to understand multiple IPC contexts, reading the IPC
00145 manual.
00146
00147 When you subscribe to (most) IPC messages, you set up a handler (and maybe
00148 message pointer) on a context-specific basis (although you only get one
00149 handler and message allocation per context).
00150
00151 So, if you wanted to navigation status messages from two simulations, you
00152 could use the following:
00153 @verbatim
00154 void connect_to_two_simulations(char *simulation1, char *simulation2,
00155 IPC_CONTEXT_PTR *context1,
00156 IPC_CONTEXT_PTR *context2)
00157 {
00158
00159 *context1 = IPC_connectModule(module_name, simulation1);
00160 carmen_navigator_subscribe_status(NULL, handler1, CARMEN_SUBSCRIBE_NOW);
00161
00162 *context2 = IPC_connectModule(module_name, simulation2);
00163 carmen_navigator_subscribe_status(NULL, handler2, CARMEN_SUBSCRIBE_NOW);
00164
00165 IPC_setContext(*context1);
00166 carmen_navigator_set_goal_place("lab door");
00167 carmen_navigator_go();
00168
00169 while (1) {
00170 IPC_setContext(*context1);
00171 sleep_ipc(1);
00172 IPC_setContext(*context2);
00173 sleep_ipc(1);
00174 }
00175 }
00176 @endverbatim
00177
00178 What this does is establish a connection with a simulation running on the
00179 \c CENTRALHOST described by simulation1, and a simulation running on
00180 \c CENTRALHOST described by simulation2. (The simulations presumably were
00181 connected earlier.) The function subscribes to navigator status messages from
00182 each simulation, using different handlers for each message. You could
00183 certainly handle messages from both simulations using the same function, using
00184 the \c IPC_CONTEXT_PTR IPC_getContext(); function inside the handler to
00185 tell which simulation generated the callback.
00186
00187 After the callbacks are established, the function goes back to the IPC context
00188 of the first simulation, sets a goal and starts the robot moving. After that,
00189 the function indefinitely just handles messages.
00190
00191 **/