root / scout / scoutsim / src / scoutsim.cpp @ 144137a1
History | View | Annotate | Download (1.46 KB)
1 | 266ae7f2 | Alex Zirbel | /*
|
---|---|---|---|
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 | a8480867 | Alex Zirbel | #include "sim_frame.h" |
21 | 266ae7f2 | Alex Zirbel | |
22 | #ifdef __WXMAC__
|
||
23 | #include <ApplicationServices/ApplicationServices.h> |
||
24 | #endif
|
||
25 | |||
26 | class ScoutApp : public wxApp |
||
27 | { |
||
28 | public:
|
||
29 | 144137a1 | Alex Zirbel | char** local_argv;
|
30 | ros::NodeHandlePtr nh; |
||
31 | 266ae7f2 | Alex Zirbel | |
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 | 144137a1 | Alex Zirbel | local_argv = new char*[ argc ]; |
47 | 266ae7f2 | Alex Zirbel | for ( int i = 0; i < argc; ++i ) |
48 | { |
||
49 | 144137a1 | Alex Zirbel | local_argv[ i ] = strdup( wxString( argv[ i ] ).mb_str() ); |
50 | 266ae7f2 | Alex Zirbel | } |
51 | |||
52 | 144137a1 | Alex Zirbel | ros::init(argc, local_argv, "scoutsim");
|
53 | nh.reset(new ros::NodeHandle);
|
||
54 | 266ae7f2 | Alex Zirbel | |
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 | 144137a1 | Alex Zirbel | free( local_argv[ i ] ); |
70 | 266ae7f2 | Alex Zirbel | } |
71 | 144137a1 | Alex Zirbel | delete [] local_argv;
|
72 | 266ae7f2 | Alex Zirbel | |
73 | return 0; |
||
74 | } |
||
75 | }; |
||
76 | |||
77 | DECLARE_APP(ScoutApp); |
||
78 | IMPLEMENT_APP(ScoutApp); |