scoutos / scout / scoutsim / src / scoutsim.cpp @ 266ae7f2
History | View | Annotate | Download (1.48 KB)
1 |
/*
|
---|---|
2 |
* This package was developed by the CMU Robotics Club project using code
|
3 |
* from Willow Garage, Inc. Please see licensing.txt for details.
|
4 |
*
|
5 |
* All rights reserved.
|
6 |
*
|
7 |
* @brief Runs the simulator, keeping track of all the scout robots.
|
8 |
* @file scoutsim.cpp
|
9 |
* @author Colony Project, CMU Robotics Club
|
10 |
* @author Alex Zirbel
|
11 |
*/
|
12 |
|
13 |
#include <wx/app.h> |
14 |
#include <wx/timer.h> |
15 |
|
16 |
#include <ros/ros.h> |
17 |
|
18 |
#include <boost/thread.hpp> |
19 |
|
20 |
#include "scoutsim/sim_frame.h" |
21 |
|
22 |
#ifdef __WXMAC__
|
23 |
#include <ApplicationServices/ApplicationServices.h> |
24 |
#endif
|
25 |
|
26 |
class ScoutApp : public wxApp |
27 |
{ |
28 |
public:
|
29 |
char** local_argv_;
|
30 |
ros::NodeHandlePtr nh_; |
31 |
|
32 |
ScoutApp() |
33 |
{ |
34 |
} |
35 |
|
36 |
bool OnInit()
|
37 |
{ |
38 |
#ifdef __WXMAC__
|
39 |
ProcessSerialNumber PSN; |
40 |
GetCurrentProcess(&PSN); |
41 |
TransformProcessType(&PSN,kProcessTransformToForegroundApplication); |
42 |
SetFrontProcess(&PSN); |
43 |
#endif
|
44 |
|
45 |
// create our own copy of argv, with regular char*s.
|
46 |
local_argv_ = new char*[ argc ]; |
47 |
for ( int i = 0; i < argc; ++i ) |
48 |
{ |
49 |
local_argv_[ i ] = strdup( wxString( argv[ i ] ).mb_str() ); |
50 |
} |
51 |
|
52 |
ros::init(argc, local_argv_, "scoutsim");
|
53 |
nh_.reset(new ros::NodeHandle);
|
54 |
|
55 |
wxInitAllImageHandlers(); |
56 |
|
57 |
scoutsim::SimFrame* frame = new scoutsim::SimFrame(NULL); |
58 |
|
59 |
SetTopWindow(frame); |
60 |
frame->Show(); |
61 |
|
62 |
return true; |
63 |
} |
64 |
|
65 |
int OnExit()
|
66 |
{ |
67 |
for ( int i = 0; i < argc; ++i ) |
68 |
{ |
69 |
free( local_argv_[ i ] ); |
70 |
} |
71 |
delete [] local_argv_;
|
72 |
|
73 |
return 0; |
74 |
} |
75 |
}; |
76 |
|
77 |
DECLARE_APP(ScoutApp); |
78 |
IMPLEMENT_APP(ScoutApp); |
79 |
|