/*
 * Function
 *	main
 *
 * Description
 *	LINUX entry point of TORCS
 *
 * Parameters
 *	
 *
 * Return
 *	
 *
 * Remarks
 *	
 */
int 
main(int argc, char *argv[])
{
    init_args(argc, argv);

    /*** kswe ***/
    	signal(SIGTERM, signal_handler);
	signal(SIGINT, signal_handler);
	user_input = (float*)init_shared_mem(&shmid_input, SHMEM, sizeof(float), size_user_input, shared_memory_input);		// shm start (input)
	torcs_output = (float*)init_shared_mem(&shmid_output, SHMEM2, sizeof(float), size_torcs_output, shared_memory_output);
	for(int i = 0; i < size_user_input; i++)
		user_input[i] = 0.0;
	for(int i = 0; i < size_torcs_output; i++)
		torcs_output[i] = 0.0;
	user_input[STEER_MODE] = 1.0;	// steering mode: lane keeping
    /************/
    
    LinuxSpecInit();		/* init specific linux functions */
    
    GfScrInit(argc, argv);	/* init screen */

    TorcsEntry();		/* launch TORCS */
    
    glutMainLoop();		/* event loop of glut */

    return 0;			/* just for the compiler, never reached */
}
示例#2
0
int main(int argc, char **argv)
{
    init_args(argc, argv);
    glutInit(&argc, argv);
    glutCreateWindow(argv[1]);
    ssgInit();
    
#ifndef WIN32
    LinuxSpecInit();
#else
    WindowsSpecInit();
#endif

    Generate();
    return 0;
}
示例#3
0
文件: main.cpp 项目: COHRINT/cuTORCS
/*
 * Function
 *	main
 *
 * Description
 *	LINUX entry point of TORCS
 *
 * Parameters
 *
 *
 * Return
 *
 *
 * Remarks
 *
 */
int
main(int argc, char *argv[])
{
	const char *raceconfig = "";

	init_args(argc, argv, &raceconfig);
	LinuxSpecInit();			/* init specific linux functions */

	if(strlen(raceconfig) == 0) {
		GfScrInit(argc, argv);	/* init screen */
		TorcsEntry();			/* launch TORCS */
		glutMainLoop();			/* event loop of glut */
	} else {
		// Run race from console, no Window, no OpenGL/OpenAL etc.
		// Thought for blind scripted AI training
		ReRunRaceOnConsole(raceconfig);
	}

	return 0;					/* just for the compiler, never reached */
}
示例#4
0
int
main(int argc, char *argv[])
{

//////////////////////////////////////////// by Chenyi 
    struct shared_use_st *shared = NULL;
    int shmid;  
    // establish memory sharing 
    shmid = shmget((key_t)4567, sizeof(struct shared_use_st), 0666|IPC_CREAT);  
    if(shmid == -1)  
    {  
        fprintf(stderr, "shmget failed\n");  
        exit(EXIT_FAILURE);  
    }  
  
    shm = shmat(shmid, 0, 0);  
    if(shm == (void*)-1)  
    {  
        fprintf(stderr, "shmat failed\n");  
        exit(EXIT_FAILURE);  
    }  
    printf("\n********** Memory sharing started, attached at %X **********\n \n", shm);  
    // set up shared memory 
    shared = (struct shared_use_st*)shm;  
    shared->written = 0;
    shared->control = 0;
    shared->pause = 0;
    shared->fast = 0.0;

    shared->dist_L = 0.0;
    shared->dist_R = 0.0;

    shared->toMarking_L = 0.0;
    shared->toMarking_M = 0.0;
    shared->toMarking_R = 0.0;

    shared->dist_LL = 0.0;
    shared->dist_MM = 0.0;
    shared->dist_RR = 0.0;

    shared->toMarking_LL = 0.0;
    shared->toMarking_ML = 0.0;
    shared->toMarking_MR = 0.0;
    shared->toMarking_RR = 0.0;

    shared->toMiddle = 0.0;
    shared->angle = 0.0;
    shared->speed = 0.0;

    shared->steerCmd = 0.0;
    shared->accelCmd = 0.0;
    shared->brakeCmd = 0.0;

    pwritten=&shared->written;
    pdata=shared->data;
    pcontrol=&shared->control;
    ppause=&shared->pause;

    psteerCmd_ghost=&shared->steerCmd;
    paccelCmd_ghost=&shared->accelCmd;
    pbrakeCmd_ghost=&shared->brakeCmd;

    pspeed_ghost=&shared->speed;
    ptoMiddle_ghost=&shared->toMiddle;
    pangle_ghost=&shared->angle;

    pfast_ghost=&shared->fast;

    pdist_L_ghost=&shared->dist_L;
    pdist_R_ghost=&shared->dist_R;

    ptoMarking_L_ghost=&shared->toMarking_L;
    ptoMarking_M_ghost=&shared->toMarking_M;
    ptoMarking_R_ghost=&shared->toMarking_R;

    pdist_LL_ghost=&shared->dist_LL;
    pdist_MM_ghost=&shared->dist_MM;
    pdist_RR_ghost=&shared->dist_RR;

    ptoMarking_LL_ghost=&shared->toMarking_LL;
    ptoMarking_ML_ghost=&shared->toMarking_ML;
    ptoMarking_MR_ghost=&shared->toMarking_MR;
    ptoMarking_RR_ghost=&shared->toMarking_RR;
/////////////////////////////////////////// by Chenyi

	const char *raceconfig = "";

	init_args(argc, argv, &raceconfig);
	LinuxSpecInit();			/* init specific linux functions */

	if(strlen(raceconfig) == 0) {
		GfScrInit(argc, argv);	/* init screen */
		TorcsEntry();			/* launch TORCS */
		glutMainLoop();			/* event loop of glut */
	} else {
		// Run race from console, no Window, no OpenGL/OpenAL etc.
		// Thought for blind scripted AI training
		ReRunRaceOnConsole(raceconfig);
	}

	return 0;					/* just for the compiler, never reached */
}