/** * Main. * * @param int number of arguments * @param char** arguments * @return int */ int main(int argc, char **argv) { // Make sure we have the minimum number of arguments if (argc != 9) { printf("Not enough arguments: %d", argc); throw; } Simulator::Config config = Simulator::Config(); // Set bitmap file locations config.real_bitmap = argv[2]; config.robot_bitmap = argv[3]; // Start position (x, y) config.start.first = atoi(argv[4]); config.start.second = atoi(argv[5]); // Goal position (x, y) config.goal.first = atoi(argv[6]); config.goal.second = atoi(argv[7]); // Robot scan radius config.scan_radius = atoi(argv[8]); // Build the simulator and draw Simulator sim = Simulator(argv[1], config); sim.draw(); return 0; }
int main() { cout << "Hello World!!!" << endl; // prints Hello World!!! string u=getenv("USER"); // string filename="/home/vapashos/JSVM/jsvm/JSVM/H264Extension/data/test.264"; // string traceFile="/home/vapashos/JSVM/jsvm/JSVM/H264Extension/data/trace.txt"; string filename="/home/"+u+"/JSVM/jsvm/JSVM/H264Extension/data/test.264"; string traceFile="/home/"+u+"/JSVM/jsvm/JSVM/H264Extension/data/trace.txt"; Simulator sim=Simulator(5,filename,traceFile); sim.createMeshTopology(); sim.s->createCodedPacket(sim.s->segments[12]); char c; for(int simTime=0;simTime<2000;simTime++){ cout<<"###############################################################"<<endl; cout<<"# TIMESLOT "<<simTime+1<<" #"<<endl; cout<<"###############################################################"<<endl; sim.simulate3GTransmissions(simTime); sim.simulateWIFIBroadcasts(simTime); //cin>>c; //sim.showChannelBuffer(); if(channel3G::status==0 ){ cout<<"All downloads on 3G finished "<<endl; if(sim.checkNodeQueues(simTime)){ cout<<"There is nothing to be transmitted inside the lan"<<endl; break; } //sim.showNodeSegmentList(); //break; } /*if(simTime%100==0) cin>>c;*/ cout<<"********************Enf OF TimeSlot "<<simTime+1<<" ***********************"<<endl; // if(simTime%2==0) //cin>>c; } cout.flush(); cout<<"*****************************************"<<endl; cout<<"finished"<<endl; cout<<"-------------------------- "<<endl; return 0; }
int main( int argc, char* args[] ) { printf("Main started\n"); Simulator sim = Simulator(1); sim.Initialize(); sim.Start(); // Add Gravity module SimulatorModule_Gravity* Gravity = new SimulatorModule_Gravity(); sim.AddModule( (SimulatorModule*) Gravity ); sim.NextTick(); //SDL_Delay(2000); sim.Stop(); return 0; }
int Manual() { int PVi, k; K= uatof(Gain); /* Things will be drawn more quickly if you always acquire the screen before trying to draw onto it. */ acquire_screen(); Graphics(); /* Call to graphics from a different function to avoid messy code */ int dir = 1; //since we are receiving data, direction should be 1 int mode = IEEE1284_MODE_COMPAT; // parameter to set mode 'receive' RLE_SPRITE *rle; /* Set the direction for reception */ ioctl(fd, PPDATADIR, &dir); ioctl(fd, PPWDATA, 0); PVi= 0; k= 100; M=0; while (!key[KEY_ESC]) /* Only pressing ESC can Exit */ { M++; /* Check if user needs some help */ if(key[KEY_F1]) Help(); k++; i= 897; Captura = create_sub_bitmap(screen, 72, 350, 898, 368); rle = get_rle_sprite(Captura); destroy_bitmap(Captura); draw_rle_sprite(screen, rle, 71, 350); destroy_rle_sprite(rle); /* This line reads data from the interfase which is the process variable(measured variable) of the system */ ioctl(fd, PPRDATA, &PVi); PV= PVi; if(PV<=40) { PV= 51; system("festival --tts Messages/Disconnected&"); blit(Disconnected, screen, 0, 0, 70, 290, 887, 52); } if(PV<=48) PVi= 51; PV= 1.794117647*(PVi-51); SP= PV; if(key[KEY_RIGHT]) { fd = close("/dev/parport0"); Simulator(); } if(key[KEY_PGUP]) OP= (OP+46); if(key[KEY_PGDN]) OP= (OP-46); if(key[KEY_UP]) OP= (OP+3.66); if(key[KEY_DOWN]) { if(OP>=1) OP= (OP-3.66); } if(key[KEY_PRTSCR]) { Captura = create_sub_bitmap(screen, 0, 0, 1024, 768); save_bitmap("images/User/Captura.pcx", Captura, pal); destroy_bitmap(Captura); } Timer++; if(OP<=0) OP= 0; if (PV>=40) { textprintf_ex(screen, font, 230, 297, BLACK, WHITE, "%3.1f", (PV/368)*100); // Medición textprintf_ex(screen, font, 450, 297, BLACK, WHITE, "%3.1f", (SP/368)*100); // SP textprintf_ex(screen, font, 710, 297, BLACK, WHITE, "%3.1f", (OP/368)*100); // Controlador } if(k>=100) { k= 0; vline(screen, 967, 351, 717, GRAY); blit(Clean, screen, 0, 0, 968, 350, 2, 368); } int Recorder; Recorder++; if(Recorder>=900) { Recorder= 0; Captura = create_sub_bitmap(screen, 258, 350, 715, 368); } Captura = create_sub_bitmap(screen, 248, 350, 705, 368); if(PV>=362) PV= 365; if(OP>=367) OP= 365; if(PV<=0) PV= 0; if(OP<=0) OP= 0; /* Draw the behaviour of the PV, SP and OP over time */ line(screen, 71+i, 717-PV, 71+i, 717-PVj, RED); PVj= PV; /* Flag for line y2 as a precedent state */ line(screen, 71+i, 717-OP, 71+i, 717-OPj, BLUE); OPj= OP; /* Flag for line y2 as a precedent state */ fprintf(outfile,"%i\t%f\t %f\t %f\n", M, ((PV/368)*100), ((SP/368)*100), ((OP/368)*100)); rest(Delay); } int ScreenWide; RLE_SPRITE *rle0, *rle1; BITMAP *Screen3; Screen3 = load_bitmap("images/Close/Base.pcx", pal); system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &"); rest(5); rle0= get_rle_sprite(Screen2); rle1= get_rle_sprite(Screen3); for(ScreenWide=0;ScreenWide<=768;ScreenWide=ScreenWide+5) { draw_rle_sprite(screen, rle0, 0, 768); draw_rle_sprite(screen, rle1, 0, -768+ScreenWide); } destroy_rle_sprite(rle0); destroy_rle_sprite(rle1); destroy_bitmap(Screen2); destroy_bitmap(Screen3); destroy_bitmap(Clean); destroy_bitmap(Disconnected); release_screen(); Close(); exit(0); }
int Manual(int argc, unsigned char **argv) { /* Serial port initialization */ fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY); if (fd == -1) { perror("open_port: Unable to open /dev/ttyS0 - "); return 1; } else { fcntl(fd, F_SETFL, 0); } getbaud(fd); initport(fd); int PVi, k; K= uatof(Gain); /* Things will be drawn more quickly if you always acquire the screen before trying to draw onto it. */ acquire_screen(); Graphics(); /* Call to graphics from a different function to avoid messy code */ RLE_SPRITE *rle; sCmd[0]= 'C'; writeport(fd, sCmd); PVi= 0; k= 100; M=0; while (!key[KEY_ESC]) /* Only pressing ESC can Exit */ { char ValveState; if(ValveState=='O') { sCmd[0]= 'A'; writeport(fd, sCmd); } if(ValveState=='C') { sCmd[0]= 'C'; writeport(fd, sCmd); } M++; /* Check if user needs some help */ if(key[KEY_F1]) Help(); k++; i= 897; Captura = create_sub_bitmap(screen, 72, 350, 898, 368); rle = get_rle_sprite(Captura); destroy_bitmap(Captura); draw_rle_sprite(screen, rle, 71, 350); destroy_rle_sprite(rle); /* This line reads data from the interfase which is the process variable(measured variable) of the system */ fcntl(fd, F_SETFL, FNDELAY); // don't block serial read readport(fd,sResult); PVi= (int) *sResult; PV= PVi; /* if(PVi<=40) { PV= 51; system("festival --tts Messages/Disconnected&"); blit(Disconnected, screen, 0, 0, 70, 290, 887, 52); } */ if(PV<=48) PVi= 51; PV= 1.794117647*(PVi-51); SP= PV; if(key[KEY_RIGHT]) { //fd = close("/dev/parport0"); Simulator(); } if(key[KEY_PGUP]) OP= (OP+46); if(key[KEY_PGDN]) OP= (OP-46); if(key[KEY_UP]) { OP=162; //(OP+3.66); sCmd[0]= 'A'; writeport(fd, sCmd); ValveState='O'; } if(key[KEY_DOWN]) { if(OP>=1) OP= 0;//(OP-3.66); sCmd[0]= 'C'; writeport(fd, sCmd); ValveState='C'; } if(key[KEY_PRTSCR]) { Captura = create_sub_bitmap(screen, 0, 0, 1024, 768); save_bitmap("images/User/Captura.pcx", Captura, pal); destroy_bitmap(Captura); } Timer++; if(OP<=0) OP= 0; // if (PV>=40) // { textprintf_ex(screen, font, 230, 297, BLACK, WHITE, "%3.1f", (PV/368)*100); // Medición textprintf_ex(screen, font, 450, 297, BLACK, WHITE, "%3.1f", (SP/368)*100); // SP textprintf_ex(screen, font, 710, 297, BLACK, WHITE, "%3.1f", (OP/368)*100); // Controlador // } if(k>=100) { k= 0; vline(screen, 967, 351, 717, GRAY); blit(Clean, screen, 0, 0, 968, 350, 2, 368); } int Recorder; Recorder++; if(Recorder>=900) { Recorder= 0; Captura = create_sub_bitmap(screen, 258, 350, 715, 368); } Captura = create_sub_bitmap(screen, 248, 350, 705, 368); if(PV>=362) PV= 365; if(OP>=367) OP= 365; if(PV<=0) PV= 0; if(OP<=0) OP= 1; /* OPi= fixtoi(itofix((OP*0.69234783)/255*100)); sCmd[0]= (unsigned char)OPi+50; sCmd[0]= sCmd[0]+0.00; writeport(fd, sCmd); */ // textprintf_ex(screen, font, 30, 297, BLACK, WHITE, "%i - %s - %3.1f", PVi, sResult, PV); // Medición /* Draw the behaviour of the PV, SP and OP over time */ line(screen, 71+i, 717-PV, 71+i, 717-PVj, RED); PVj= PV; /* Flag for line y2 as a precedent state */ line(screen, 71+i, 717-OP, 71+i, 717-OPj, BLUE); OPj= OP; /* Flag for line y2 as a precedent state */ fprintf(outfile,"%i\t%f\t %f\t %f\n", M, ((PV/368)*100), ((SP/368)*100), ((OP/368)*100)); rest(Delay); } int ScreenWide; RLE_SPRITE *rle0, *rle1; BITMAP *Screen3; Screen3 = load_bitmap("images/Close/Base.pcx", pal); system("mp3blaster /home/mentesuprema/Residencia/sounds/swing2.wav &"); rest(5); rle0= get_rle_sprite(Screen2); rle1= get_rle_sprite(Screen3); for(ScreenWide=0;ScreenWide<=768;ScreenWide=ScreenWide+5) { draw_rle_sprite(screen, rle0, 0, 768); draw_rle_sprite(screen, rle1, 0, -768+ScreenWide); } destroy_rle_sprite(rle0); destroy_rle_sprite(rle1); destroy_bitmap(Screen2); destroy_bitmap(Screen3); destroy_bitmap(Clean); destroy_bitmap(Disconnected); release_screen(); Close(); exit(0); }
void Selection (int argc, char **argv) { clear (); refresh (); flushinp (); struct passwd *user = getpwnam (getlogin ()); attrset (A_BOLD); box (stdscr, 0, 0); attrset (A_NORMAL); mvaddstr (4, 3, " OOOOOOOOOO O"); mvaddstr (5, 3, " O OOO OOOOOOO"); mvaddstr (6, 3, "O O"); mvaddstr (7, 3, "OOOOOOOOOOOOOOOOOOOOOOOO"); mvaddstr (8, 3, " OOOOO OOOOO"); mvaddstr (9, 3, " OOO OOO"); mvaddstr (2, 34, " /--\\ /--\\"); mvaddstr (3, 34, " / || \\ / || \\"); mvaddstr (4, 34, " / || \\ / || \\"); mvaddstr (5, 34, " / || \\ / || \\"); mvaddstr (6, 34, " / || \\ / || \\"); mvaddstr (7, 34, " / || \\______/ || \\"); mvaddstr (8, 34, " / || || \\"); mvaddstr (9, 34, "__/ || || \\__"); attrset (A_STANDOUT); mvaddstr (11, 1, ":::::::::::::::..."); mvaddstr (11, 59, "...:::::::::::::::::"); attrset (A_NORMAL); attrset (A_REVERSE); mvaddstr (11, 19, "WELCOME TO THE VEHICLE DRIVING SIMULATOR"); attrset (A_NORMAL); mvaddstr (13, 4, "With the freeway under construction traffic has "); mvaddstr (13, 52, "reached critical mass."); mvprintw (14, 4, "%s, what kind of vehicle would you like to drive?", user->pw_gecos); attrset (A_BOLD | A_BLINK); mvprintw (2, 6, "Hi %s!", user->pw_name); attrset (A_NORMAL); attrset (A_BOLD); mvprintw (14, 4, "%s", user->pw_gecos); mvaddstr (16, 23, "For a regular car, press..... C"); mvaddstr (17, 23, "For a fast truck, press...... T"); mvaddstr (18, 23, "For a slow bus, press........ B"); mvaddstr (19, 23, "To quit simulator, press..... ESC"); attrset (A_NORMAL); mvaddstr (22, 19, "Your vehicle will be illustrated in bold."); int distance = DEFAULT_DISTANCE, again = 1; while (again) switch (getch ()) { case 'c': case 'C': case '\n': SelectDistance (argc, argv, distance); Simulator (new Car (distance), "Car", distance); again = 0; break; case 't': case 'T': SelectDistance (argc, argv, distance); Simulator (new Truck (distance), "Truck", distance); again = 0; break; case 'b': case 'B': SelectDistance (argc, argv, distance); Simulator (new Bus (distance), "Bus", distance); again = 0; break; case 033: clear (); refresh (); endwin (); exit (0); default: beep (); again = 1; } }
int main(int argc, char **argv) { //ROS stuff ros::init(argc, argv, "simulate_node"); ros::NodeHandle n; ros::Publisher filter_target_pub = n.advertise<laser_package::state>("/filter_topic",1000); //publish targets to new topic //ros::ServiceClient client_update = n.serviceClient<laser_package::update_tracker>("updateFilter"); //ros::ServiceClient client_initialize = n.serviceClient<laser_package::update_tracker>("initializeFilter"); laser_package::update_tracker srv; laser_package::state state_msg; ros::Rate r(floor(1/SAMPLING_INTERVAL+0.5)); //random noise stuff std::default_random_engine measurement_generator; std::normal_distribution<double> meas_noise(MU_W_SIMULATE,VAR_W_SIMULATE); //simulator class Simulator simulator = Simulator(); //other variables Eigen::VectorXd next_x(5), past_x(5); double w; past_x << 0, 10, 0, 0, OMEGA_RADS; // initial vector: xi, xi_dot, eta, eta_dot, omega simulator.initializeSimulators(past_x); /*srv.request.initial_x = past_x(XI); srv.request.initial_x_velocity = past_x(XI_DOT); srv.request.initial_y = past_x(ETA); srv.request.initial_y_velocity = past_x(ETA_DOT); srv.request.initial_turn_rate = past_x(OMEGA); srv.request.sampling_interval = SAMPLING_INTERVAL; srv.request.update_time = ros::Time::now().toSec(); srv.request.measurement_noise_mean = MU_W; srv.request.measurement_noise_variance = VAR_W;*/ //initialize tracker(s) int counter = 0; //client_initialize.call(srv); while(ros::ok()) { w = meas_noise(measurement_generator);//noises if(counter<300) { next_x = simulator.simulateCoordinatedTurn(OMEGA_RADS); //next_x = simulator.simulateUniformMotion(); } else if (counter>300&counter<500) { //next_x = simulator.simulateUniformMotion(); next_x = simulator.simulateCoordinatedTurn(OMEGA_RADS); } else if (counter>500&&counter<1100) { next_x = simulator.simulateUniformMotion(); //next_x = simulator.simulateCoordinatedTurn(OMEGA_RADS); } else { next_x = simulator.simulateUniformMotion(); //next_x = simulator.simulateCoordinatedTurn(OMEGA_RADS); } //update values state_msg.Real_X = next_x(XI); state_msg.Measured_X = next_x(XI) + w; state_msg.Real_Y = next_x(ETA); state_msg.Measured_Y = next_x(ETA) + w; state_msg.Time_Of_Measurement = ros::Time::now().toSec(); filter_target_pub.publish(state_msg); counter++; //send update //if(client_update.call(srv)); ros::spinOnce(); r.sleep(); } return 0; }