servers/usarsim/main.cc File Reference

#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cstdarg>
#include <unistd.h>
#include <netdb.h>
#include <limits.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <arpa/inet.h>
#include <netinet/tcp.h>
#include <pthread.h>
#include <signal.h>
#include "config.h"
#include "images.h"
#include <Platform.h>
#include <Primitives.h>
#include <OPENR/ODataFormats.h>

Go to the source code of this file.

Defines

#define USARSIM
#define CHECK_SYSCALL(val, msg)   if ((val) < 0) { perror(msg); exit(4); }

Enumerations

enum  team_type { NO_TEAM, TEAM_BLUE, TEAM_RED }

Functions

const char * team_str (void)
bool connect_to_usarsim (int *sock, int port=usarsim_port, bool read_init_msg=true)
int connect_to_opensdk_sensor (const char *MSdir, const char *socket_name)
int connect_to_opensdk_actuator (const char *MSdir)
void send_usarsim (int sock, const char *format,...) PRINTF_FORMAT
void * read_usarsim_messages (void *)
void * read_usarsim_images (void *MSdir)
void read_opensdk_messages (void)
void sigalrm_handler (int)
int main (int argc, char *argv[])

Variables

team_type team = DEFAULT_USARSIM_ROBOT_TEAM
const char * usarsim_host = DEFAULT_USARSIM_HOST
short usarsim_port = DEFAULT_USARSIM_PORT
short usarsim_imgserver_port = DEFAULT_USARSIM_IMGSERVER_PORT
const char * usarsim_robot = DEFAULT_USARSIM_ROBOT
const char * usarsim_location = DEFAULT_USARSIM_LOCATION
const char * usarsim_ball_location = DEFAULT_USARSIM_BALL_LOCATION
bool display_fps = DEFAULT_DISPLAY_IMAGE_FPS
int usarsim_socket
int usarsim_ball_socket
FILE * usarsim_imgserver_socket
int actuators_socket
FILE * sensors_socket
double joint_values [num_of_primitives] = {INT_MIN}


Define Documentation

#define CHECK_SYSCALL val,
msg   )     if ((val) < 0) { perror(msg); exit(4); }
 

Definition at line 46 of file servers/usarsim/main.cc.

#define USARSIM
 

Definition at line 42 of file servers/usarsim/main.cc.


Enumeration Type Documentation

enum team_type
 

Enumeration values:
NO_TEAM 
TEAM_BLUE 
TEAM_RED 

Definition at line 50 of file servers/usarsim/main.cc.


Function Documentation

int connect_to_opensdk_actuator const char *  MSdir  )  [static]
 

createa Unix socket so that openSDK can connect to it (for actuators)

Definition at line 168 of file servers/usarsim/main.cc.

References ACTUATORS_SERVER_SOCKET, CHECK_SYSCALL, and sock.

Referenced by main().

int connect_to_opensdk_sensor const char *  MSdir,
const char *  socket_name
[static]
 

connect to a openSDK sensors Unix socket, located in the MS dir

Definition at line 141 of file servers/usarsim/main.cc.

References opensdk_yield.

Referenced by main(), and read_usarsim_images().

bool connect_to_usarsim int *  sock,
int  port = usarsim_port,
bool  read_init_msg = true
[static]
 

connect to the usarsim server. returns true on success or false otherwise.

Definition at line 88 of file servers/usarsim/main.cc.

References memcpy(), sock, and usarsim_host.

Referenced by main(), and read_usarsim_images().

int main int  argc,
char *  argv[]
 

Definition at line 452 of file servers/usarsim/main.cc.

References actuators_socket, connect_to_opensdk_actuator(), connect_to_opensdk_sensor(), connect_to_usarsim(), DEFAULT_DISPLAY_IMAGE_FPS, DEFAULT_USARSIM_BALL_LOCATION, DEFAULT_USARSIM_HOST, DEFAULT_USARSIM_LOCATION, DEFAULT_USARSIM_PORT, DEFAULT_USARSIM_ROBOT, display_fps, read_opensdk_messages(), read_usarsim_images(), read_usarsim_messages(), send_usarsim(), SENSORS_SERVER_SOCKET, sensors_socket, sigalrm_handler(), team, team_str(), usarsim_ball_location, usarsim_ball_socket, usarsim_host, usarsim_location, usarsim_port, usarsim_robot, and usarsim_socket.

void read_opensdk_messages void   )  [static]
 

receive messages from openSDK and process them (and forward them to USARSim in appropriate)

Definition at line 402 of file servers/usarsim/main.cc.

References actuators_socket, and joint_values.

Referenced by main().

void* read_usarsim_images void *  MSdir  )  [static]
 

read images sent by the USARSim image server and feed them back to openSDK

Definition at line 279 of file servers/usarsim/main.cc.

References byte, connect_to_opensdk_sensor(), connect_to_usarsim(), IMAGE_SERVER_SOCKET, IMG_HEIGHT, IMG_SIZE, IMG_WIDTH, RGB_to_YCbCr(), shrink_frame(), usarsim_imgserver_port, and usarsim_imgserver_socket.

Referenced by main().

void* read_usarsim_messages void *   )  [static]
 

receive messages from USARSim and process them (and forward them to openSDK if appropriate)

Definition at line 215 of file servers/usarsim/main.cc.

References sensors_socket, and usarsim_socket.

Referenced by main().

void send_usarsim int  sock,
const char *  format,
  ...
[static]
 

send data to the USARSim server. If debugging is active it also prints the string sent

Definition at line 193 of file servers/usarsim/main.cc.

References sock.

Referenced by main(), and sigalrm_handler().

void sigalrm_handler int   )  [static]
 

Definition at line 425 of file servers/usarsim/main.cc.

References joint_values, memcpy(), send_usarsim(), sensors_socket, and usarsim_socket.

Referenced by main().

const char* team_str void   )  [static]
 

return a string corresponding to the chosen team

Definition at line 75 of file servers/usarsim/main.cc.

References NO_TEAM, TEAM_BLUE, and TEAM_RED.

Referenced by main().


Variable Documentation

int actuators_socket [static]
 

Definition at line 68 of file servers/usarsim/main.cc.

Referenced by main(), and read_opensdk_messages().

bool display_fps = DEFAULT_DISPLAY_IMAGE_FPS [static]
 

Definition at line 63 of file servers/usarsim/main.cc.

Referenced by main().

double joint_values[num_of_primitives] = {INT_MIN} [static]
 

Definition at line 71 of file servers/usarsim/main.cc.

Referenced by read_opensdk_messages(), and sigalrm_handler().

FILE* sensors_socket [static]
 

Definition at line 69 of file servers/usarsim/main.cc.

Referenced by main(), read_usarsim_messages(), and sigalrm_handler().

team_type team = DEFAULT_USARSIM_ROBOT_TEAM [static]
 

Definition at line 56 of file servers/usarsim/main.cc.

Referenced by main().

const char* usarsim_ball_location = DEFAULT_USARSIM_BALL_LOCATION [static]
 

Definition at line 62 of file servers/usarsim/main.cc.

Referenced by main().

int usarsim_ball_socket [static]
 

Definition at line 66 of file servers/usarsim/main.cc.

Referenced by main().

const char* usarsim_host = DEFAULT_USARSIM_HOST [static]
 

Definition at line 57 of file servers/usarsim/main.cc.

Referenced by connect_to_usarsim(), and main().

short usarsim_imgserver_port = DEFAULT_USARSIM_IMGSERVER_PORT [static]
 

Definition at line 59 of file servers/usarsim/main.cc.

Referenced by read_usarsim_images().

FILE* usarsim_imgserver_socket [static]
 

Definition at line 67 of file servers/usarsim/main.cc.

Referenced by read_usarsim_images().

const char* usarsim_location = DEFAULT_USARSIM_LOCATION [static]
 

Definition at line 61 of file servers/usarsim/main.cc.

Referenced by main().

short usarsim_port = DEFAULT_USARSIM_PORT [static]
 

Definition at line 58 of file servers/usarsim/main.cc.

Referenced by main().

const char* usarsim_robot = DEFAULT_USARSIM_ROBOT [static]
 

Definition at line 60 of file servers/usarsim/main.cc.

Referenced by main().

int usarsim_socket [static]
 

Definition at line 65 of file servers/usarsim/main.cc.

Referenced by main(), read_usarsim_messages(), and sigalrm_handler().


Generated on Sun Dec 2 23:04:31 2007 for openSDK by  doxygen 1.3.9.1