Revision 594c3bb9

View differences:

scout/scoutsim/src/sim_frame.cpp
75 75
        Connect(wxEVT_PAINT, wxPaintEventHandler(SimFrame::onPaint),
76 76
                NULL, this);
77 77

  
78
        std::string scouts[SCOUTSIM_NUM_SCOUTS] = 
79
        {
80
            "scout.png"
81
        };
82

  
83
        std::string images_path = ros::package::getPath("scoutsim")+"/images/";
84
        for (size_t i = 0; i < SCOUTSIM_NUM_SCOUTS; ++i)
85
        {
86
            scout_images[i].LoadFile(
87
                wxString::FromAscii((images_path + scouts[i]).c_str()));
88
            scout_images[i].SetMask(true);
89
            scout_images[i].SetMaskColour(255, 255, 255);
90
        }
78
        images_path = ros::package::getPath("scoutsim") + "/images/";
91 79

  
92
        /// @todo This should change.
93
        meter = scout_images[0].GetHeight();
80
        // 200 pixels per meter. @todo make this a constant elsewhere.
81
        meter = 200;
94 82

  
95 83
        map_base_name =  ros::package::getPath("scoutsim") + "/maps/" +
96 84
                           map_name + ".bmp";
......
239 227
            }
240 228
        }
241 229

  
230
        wxImage scout_image;
231

  
232
        // Try to load a name-specific image; if not, load the default scout
233
        string specific_name = images_path + name + ".png";
234
        if (fileExists(specific_name))
235
        {
236
            scout_image.LoadFile(wxString::FromAscii(specific_name.c_str()));
237
            scout_image.SetMask(true);
238
            scout_image.SetMaskColour(255, 255, 255);
239
        }
240
        else
241
        {
242
            scout_image.LoadFile(
243
                wxString::FromAscii((images_path + "scout.png").c_str()));
244
            scout_image.SetMask(true);
245
            scout_image.SetMaskColour(255, 255, 255);
246
        }
247

  
242 248
        ScoutPtr t(new Scout(ros::NodeHandle(real_name),
243
                   scout_images[rand() % SCOUTSIM_NUM_SCOUTS],
244
                   Vector2(x, y), &path_bitmap,angle));
249
                   scout_image, Vector2(x, y), &path_bitmap, angle));
245 250
        scouts[real_name] = t;
246 251

  
247 252
        ROS_INFO("Spawning scout [%s] at x=[%f], y=[%f], theta=[%f]",
......
338 343
        }
339 344
    }
340 345

  
346
    bool SimFrame::fileExists(const std::string& filename)
347
    {
348
        struct stat buf;
349
        if (stat(filename.c_str(), &buf) != -1)
350
        {
351
            return true;
352
        }
353
        return false;
354
    }
355

  
341 356
    void SimFrame::stopTeleop(wxCommandEvent& event)
342 357
    {
343 358
        teleop_type = TELEOP_OFF;
scout/scoutsim/src/sim_frame.h
51 51
#include <wx/string.h>
52 52
#include <wx/utils.h>
53 53

  
54
#include <sys/stat.h>
55

  
54 56
#include <ros/ros.h>
55 57

  
56 58
#include <std_srvs/Empty.h>
......
111 113
            void onUpdate(wxTimerEvent& evt);
112 114
            void onPaint(wxPaintEvent& evt);
113 115

  
116
            bool fileExists(const std::string& filename);
117

  
114 118
            void teleop_move_precise();
115 119
            void teleop_move_fluid();
116 120
            void teleop();
......
160 164
            M_Scout scouts;
161 165
            uint32_t id_counter;
162 166

  
163
            wxImage scout_images[SCOUTSIM_NUM_SCOUTS];
167
            std::string images_path;
164 168

  
165 169
            float meter;
166 170
            float width_in_meters;

Also available in: Unified diff