Project

General

Profile

Revision 8db47e6e

ID8db47e6ef5abeb5fc72fac4588d282e97960ec1f
Parent 3f5aa522
Child 071e2c1c

Added by Tahm over 10 years ago

Compiling map library, about to update buggysim to use it

View differences:

Todo.txt
43 43
[ ] I can plot a buggy in real-life onto the visualizer
44 44

  
45 45
Design Work:
46
1. rename buggymsgs into buggycommon
47
2. add buggymaps package
48
3. Use parameter server to load maps
49
   - mapname/map?
50
   - offset
51
4. rearchitect simulator into "sim" and "visualizer"
52
5. Document each package, fill out package.xml and cmakelist
53

  
54
6. be able to save run data into a new map.
55
7. design map-merge facilities
46
[x] 1. rename buggymsgs into buggycommon
47
[ ] 2. add buggymaps package
48
[ ] 3. Use parameter server to load maps
49
     - mapname/map?
50
     - offset
51
[ ] 4. rearchitect simulator into "sim" and "visualizer"
52
[ ] 5. Document each package, fill out package.xml and cmakelist
53
   - Include .h files in all cmakelists; buggysim
54

  
55
[ ] 6. be able to save run data into a new map.
56
[ ] 7. design map-merge facilities
56 57

  
57 58

  
58 59
Week 4 (due 1/11)
buggymaps/CMakeLists.txt
1
cmake_minimum_required(VERSION 2.8.3)
2
project(buggymaps)
3

  
4
## Find catkin macros and libraries
5
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
6
## is used, also find other catkin packages
7
find_package(catkin REQUIRED COMPONENTS
8
  roscpp
9
  rospy
10
  std_msgs
11
  buggycommon
12
)
13

  
14
find_package(Qt4 4.6 REQUIRED COMPONENTS QtCore QtGui)
15
include(${QT_USE_FILE})
16
find_package(Boost REQUIRED COMPONENTS thread)
17

  
18
include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${QT_INCLUDE_DIRS})
19
link_directories(${catkin_LIBRARY_DIRS})
20

  
21

  
22
# Load components
23
set(buggymaps_HDRS
24
  src/buggymaps.h
25
)
26

  
27
set(buggymaps_SRCS
28
  src/buggymaps.cpp
29
)
30

  
31
# load QT components
32
qt4_wrap_cpp(buggymaps_MOCS ${buggymaps_HDRS})
33

  
34

  
35
catkin_package(
36
  LIBRARIES buggymaps
37
)
38

  
39
###########
40
## Build ##
41
###########
42

  
43
## Specify additional locations of header files
44
## Your package locations should be listed before other locations
45
# include_directories(include)
46
#include_directories(
47
#  ${catkin_INCLUDE_DIRS}
48
#)
49

  
50
## Declare a cpp library
51
add_library(buggymaps
52
  ${buggymaps_SRCS}
53
  ${buggymaps_MOCS}
54
)
55

  
56
target_link_libraries(buggymaps
57
  ${catkin_LIBRARIES}
58
  ${boost_LIBRARIES}
59
  ${QT_LIBRARIES}
60
)
61
## Declare a cpp executable
62
# add_executable(buggymaps_node src/buggymaps_node.cpp)
63

  
64
## Add cmake target dependencies of the executable/library
65
## as an example, message headers may need to be generated before nodes
66
# add_dependencies(buggymaps_node buggymaps_generate_messages_cpp)
67

  
68
## Specify libraries to link a library or executable target against
69
# target_link_libraries(buggymaps_node
70
#   ${catkin_LIBRARIES}
71
# )
72

  
73
#############
74
## Install ##
75
#############
76

  
77
# all install targets should use catkin DESTINATION variables
78
# See http://ros.org/doc/api/catkin/html/adv_user_guide/variables.html
79

  
80
## Mark executable scripts (Python etc.) for installation
81
## in contrast to setup.py, you can choose the destination
82
# install(PROGRAMS
83
#   scripts/my_python_script
84
#   DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
85
# )
86

  
87
## Mark executables and/or libraries for installation
88
# install(TARGETS buggymaps buggymaps_node
89
#   ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
90
#   LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
91
#   RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
92
# )
93

  
94
## Mark cpp header files for installation
95
# install(DIRECTORY include/${PROJECT_NAME}/
96
#   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
97
#   FILES_MATCHING PATTERN "*.h"
98
#   PATTERN ".svn" EXCLUDE
99
# )
100

  
101
## Mark other files for installation (e.g. launch and bag files, etc.)
102
# install(FILES
103
#   # myfile1
104
#   # myfile2
105
#   DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
106
# )
107

  
108
#############
109
## Testing ##
110
#############
111

  
112
## Add gtest based cpp test target and link libraries
113
# catkin_add_gtest(${PROJECT_NAME}-test test/test_buggymaps.cpp)
114
# if(TARGET ${PROJECT_NAME}-test)
115
#   target_link_libraries(${PROJECT_NAME}-test ${PROJECT_NAME})
116
# endif()
117

  
118
## Add folders to be run by python nosetests
119
# catkin_add_nosetests(test)
buggymaps/CMakeLists.txt.user
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!DOCTYPE QtCreatorProject>
3
<!-- Written by Qt Creator 2.4.1, 2014-01-01T19:34:35. -->
4
<qtcreator>
5
 <data>
6
  <variable>ProjectExplorer.Project.ActiveTarget</variable>
7
  <value type="int">0</value>
8
 </data>
9
 <data>
10
  <variable>ProjectExplorer.Project.EditorSettings</variable>
11
  <valuemap type="QVariantMap">
12
   <value type="bool" key="EditorConfiguration.AutoIndent">true</value>
13
   <value type="bool" key="EditorConfiguration.AutoSpacesForTabs">false</value>
14
   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.0">
15
    <value type="QString" key="language">Cpp</value>
16
    <valuemap type="QVariantMap" key="value">
17
     <value type="QString" key="CurrentPreferences">CppGlobal</value>
18
    </valuemap>
19
   </valuemap>
20
   <valuemap type="QVariantMap" key="EditorConfiguration.CodeStyle.1">
21
    <value type="QString" key="language">QmlJS</value>
22
    <valuemap type="QVariantMap" key="value">
23
     <value type="QString" key="CurrentPreferences">QmlJSGlobal</value>
24
    </valuemap>
25
   </valuemap>
26
   <value type="int" key="EditorConfiguration.CodeStyle.Count">2</value>
27
   <value type="QByteArray" key="EditorConfiguration.Codec">System</value>
28
   <value type="bool" key="EditorConfiguration.ConstrainTooltips">false</value>
29
   <value type="int" key="EditorConfiguration.IndentSize">4</value>
30
   <value type="bool" key="EditorConfiguration.MouseNavigation">true</value>
31
   <value type="int" key="EditorConfiguration.PaddingMode">1</value>
32
   <value type="bool" key="EditorConfiguration.ScrollWheelZooming">true</value>
33
   <value type="int" key="EditorConfiguration.SmartBackspaceBehavior">2</value>
34
   <value type="bool" key="EditorConfiguration.SpacesForTabs">true</value>
35
   <value type="int" key="EditorConfiguration.TabKeyBehavior">0</value>
36
   <value type="int" key="EditorConfiguration.TabSize">8</value>
37
   <value type="bool" key="EditorConfiguration.UseGlobal">true</value>
38
   <value type="int" key="EditorConfiguration.Utf8BomBehavior">1</value>
39
   <value type="bool" key="EditorConfiguration.addFinalNewLine">true</value>
40
   <value type="bool" key="EditorConfiguration.cleanIndentation">true</value>
41
   <value type="bool" key="EditorConfiguration.cleanWhitespace">true</value>
42
   <value type="bool" key="EditorConfiguration.inEntireDocument">false</value>
43
  </valuemap>
44
 </data>
45
 <data>
46
  <variable>ProjectExplorer.Project.PluginSettings</variable>
47
  <valuemap type="QVariantMap"/>
48
 </data>
49
 <data>
50
  <variable>ProjectExplorer.Project.Target.0</variable>
51
  <valuemap type="QVariantMap">
52
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Desktop</value>
53
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
54
   <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.DefaultCMakeTarget</value>
55
   <value type="int" key="ProjectExplorer.Target.ActiveBuildConfiguration">0</value>
56
   <value type="int" key="ProjectExplorer.Target.ActiveDeployConfiguration">0</value>
57
   <value type="int" key="ProjectExplorer.Target.ActiveRunConfiguration">0</value>
58
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.BuildConfiguration.0">
59
    <value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.BuildDirectory">/home/tahm/buggyworkspace/build/buggymaps</value>
60
    <value type="QString" key="CMakeProjectManager.CMakeBuildConfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
61
    <value type="QString" key="ProjectExplorer.BuildCOnfiguration.ToolChain">ProjectExplorer.ToolChain.Gcc:/usr/bin/g++.x86-linux-generic-elf-32bit./usr/bin/gdb</value>
62
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
63
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
64
      <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments"></value>
65
      <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
66
      <value type="bool" key="CMakeProjectManager.MakeStep.Clean">false</value>
67
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
68
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
69
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
70
     </valuemap>
71
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
72
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Build</value>
73
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
74
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Build</value>
75
    </valuemap>
76
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.1">
77
     <valuemap type="QVariantMap" key="ProjectExplorer.BuildStepList.Step.0">
78
      <value type="QString" key="CMakeProjectManager.MakeStep.AdditionalArguments">clean</value>
79
      <valuelist type="QVariantList" key="CMakeProjectManager.MakeStep.BuildTargets"/>
80
      <value type="bool" key="CMakeProjectManager.MakeStep.Clean">true</value>
81
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Make</value>
82
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
83
      <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.MakeStep</value>
84
     </valuemap>
85
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">1</value>
86
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Clean</value>
87
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
88
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Clean</value>
89
    </valuemap>
90
    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">2</value>
91
    <value type="bool" key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment">false</value>
92
    <valuelist type="QVariantList" key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges"/>
93
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">all</value>
94
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
95
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">CMakeProjectManager.CMakeBuildConfiguration</value>
96
   </valuemap>
97
   <value type="int" key="ProjectExplorer.Target.BuildConfigurationCount">1</value>
98
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.DeployConfiguration.0">
99
    <valuemap type="QVariantMap" key="ProjectExplorer.BuildConfiguration.BuildStepList.0">
100
     <value type="int" key="ProjectExplorer.BuildStepList.StepsCount">0</value>
101
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Deploy</value>
102
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
103
     <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.BuildSteps.Deploy</value>
104
    </valuemap>
105
    <value type="int" key="ProjectExplorer.BuildConfiguration.BuildStepListCount">1</value>
106
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">No deployment</value>
107
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
108
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.DefaultDeployConfiguration</value>
109
   </valuemap>
110
   <value type="int" key="ProjectExplorer.Target.DeployConfigurationCount">1</value>
111
   <valuemap type="QVariantMap" key="ProjectExplorer.Target.RunConfiguration.0">
112
    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
113
    <value type="bool" key="Analyzer.Project.UseGlobal">true</value>
114
    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
115
    <valuelist type="QVariantList" key="Analyzer.Valgrind.AddedSuppressionFiles"/>
116
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
117
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectBusEvents">false</value>
118
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
119
    <value type="bool" key="Analyzer.Valgrind.Callgrind.CollectSystime">false</value>
120
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
121
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableBranchSim">false</value>
122
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
123
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableCacheSim">false</value>
124
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
125
    <value type="bool" key="Analyzer.Valgrind.Callgrind.EnableEventToolTips">true</value>
126
    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
127
    <value type="double" key="Analyzer.Valgrind.Callgrind.MinimumCostRatio">0.01</value>
128
    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
129
    <value type="double" key="Analyzer.Valgrind.Callgrind.VisualisationMinimumCostRatio">10</value>
130
    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
131
    <value type="bool" key="Analyzer.Valgrind.FilterExternalIssues">true</value>
132
    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
133
    <value type="int" key="Analyzer.Valgrind.NumCallers">25</value>
134
    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
135
    <valuelist type="QVariantList" key="Analyzer.Valgrind.RemovedSuppressionFiles"/>
136
    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
137
    <value type="bool" key="Analyzer.Valgrind.TrackOrigins">true</value>
138
    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
139
    <value type="QString" key="Analyzer.Valgrind.ValgrindExecutable">valgrind</value>
140
    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
141
     <value type="int">0</value>
142
     <value type="int">1</value>
143
     <value type="int">2</value>
144
     <value type="int">3</value>
145
     <value type="int">4</value>
146
     <value type="int">5</value>
147
     <value type="int">6</value>
148
     <value type="int">7</value>
149
     <value type="int">8</value>
150
     <value type="int">9</value>
151
     <value type="int">10</value>
152
     <value type="int">11</value>
153
     <value type="int">12</value>
154
     <value type="int">13</value>
155
     <value type="int">14</value>
156
    </valuelist>
157
    <valuelist type="QVariantList" key="Analyzer.Valgrind.VisibleErrorKinds">
158
     <value type="int">0</value>
159
     <value type="int">1</value>
160
     <value type="int">2</value>
161
     <value type="int">3</value>
162
     <value type="int">4</value>
163
     <value type="int">5</value>
164
     <value type="int">6</value>
165
     <value type="int">7</value>
166
     <value type="int">8</value>
167
     <value type="int">9</value>
168
     <value type="int">10</value>
169
     <value type="int">11</value>
170
     <value type="int">12</value>
171
     <value type="int">13</value>
172
     <value type="int">14</value>
173
    </valuelist>
174
    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Arguments"></value>
175
    <value type="int" key="ProjectExplorer.CustomExecutableRunConfiguration.BaseEnvironmentBase">2</value>
176
    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.Executable"></value>
177
    <value type="bool" key="ProjectExplorer.CustomExecutableRunConfiguration.UseTerminal">false</value>
178
    <valuelist type="QVariantList" key="ProjectExplorer.CustomExecutableRunConfiguration.UserEnvironmentChanges"/>
179
    <value type="QString" key="ProjectExplorer.CustomExecutableRunConfiguration.WorkingDirectory">%{buildDir}</value>
180
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName">Custom Executable</value>
181
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.DisplayName"></value>
182
    <value type="QString" key="ProjectExplorer.ProjectConfiguration.Id">ProjectExplorer.CustomExecutableRunConfiguration</value>
183
    <value type="uint" key="RunConfiguration.QmlDebugServerPort">3768</value>
184
    <value type="bool" key="RunConfiguration.UseCppDebugger">true</value>
185
    <value type="bool" key="RunConfiguration.UseQmlDebugger">false</value>
186
    <value type="bool" key="RunConfiguration.UseQmlDebuggerAuto">false</value>
187
   </valuemap>
188
   <value type="int" key="ProjectExplorer.Target.RunConfigurationCount">1</value>
189
  </valuemap>
190
 </data>
191
 <data>
192
  <variable>ProjectExplorer.Project.TargetCount</variable>
193
  <value type="int">1</value>
194
 </data>
195
 <data>
196
  <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
197
  <value type="QString">{0509d71f-18a9-4f6f-aa06-6baf391d5a04}</value>
198
 </data>
199
 <data>
200
  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
201
  <value type="int">10</value>
202
 </data>
203
</qtcreator>
buggymaps/package.xml
1
<?xml version="1.0"?>
2
<package>
3
  <name>buggymaps</name>
4
  <version>0.0.1</version>
5
  <description>The buggymaps package</description>
6

  
7
  <!-- One maintainer tag required, multiple allowed, one person per tag --> 
8
  <!-- Example:  -->
9
  <!-- <maintainer email="jane.doe@example.com">Jane Doe</maintainer> -->
10
  <maintainer email="tahm@todo.todo">tahm</maintainer>
11

  
12

  
13
  <!-- One license tag required, multiple allowed, one license per tag -->
14
  <!-- Commonly used license strings: -->
15
  <!--   BSD, MIT, Boost Software License, GPLv2, GPLv3, LGPLv2.1, LGPLv3 -->
16
  <license>TODO</license>
17

  
18

  
19
  <!-- Url tags are optional, but mutiple are allowed, one per tag -->
20
  <!-- Optional attribute type can be: website, bugtracker, or repository -->
21
  <!-- Example: -->
22
  <!-- <url type="website">http://wiki.ros.org/buggymaps</url> -->
23

  
24

  
25
  <!-- Author tags are optional, mutiple are allowed, one per tag -->
26
  <!-- Authors do not have to be maintianers, but could be -->
27
  <!-- Example: -->
28
  <!-- <author email="jane.doe@example.com">Jane Doe</author> -->
29

  
30

  
31
  <!-- The *_depend tags are used to specify dependencies -->
32
  <!-- Dependencies can be catkin packages or system dependencies -->
33
  <!-- Examples: -->
34
  <!-- Use build_depend for packages you need at compile time: -->
35
  <!--   <build_depend>message_generation</build_depend> -->
36
  <!-- Use buildtool_depend for build tool packages: -->
37
  <!--   <buildtool_depend>catkin</buildtool_depend> -->
38
  <!-- Use run_depend for packages you need at runtime: -->
39
  <!--   <run_depend>message_runtime</run_depend> -->
40
  <!-- Use test_depend for packages you need only for testing: -->
41
  <!--   <test_depend>gtest</test_depend> -->
42
  <buildtool_depend>catkin</buildtool_depend>
43
 
44

  
45
  <build_depend>roscpp</build_depend>
46
  <build_depend>buggycommon/</build_depend>
47

  
48
  <run_depend>roscpp</run_depend>
49
  <run_depend>buggycommon/</run_depend>
50

  
51

  
52
  <!-- The export tag contains other, unspecified, tags -->
53
  <export>
54
    <!-- You can specify that this package is a metapackage here: -->
55
    <!-- <metapackage/> -->
56

  
57
    <!-- Other tools can request additional information be placed here -->
58

  
59
  </export>
60
</package>
buggymaps/src/buggymaps.cpp
1
#include "buggymaps.h"
2

  
3
#include <ros/ros.h>
4
#include <fstream>
5
#include <cstdlib>
6
#include <ctime>
7

  
8
#define DEFAULT_BG_R 0x45
9
#define DEFAULT_BG_G 0x56
10
#define DEFAULT_BG_B 0xff
11

  
12
// TODO: add meter_ parameter
13
namespace buggymaps
14
{
15
  bool file_exist(QString fileName)
16
  {
17
    std::ifstream infile(fileName.toUtf8().constData());
18
    return infile.good();
19
  }
20

  
21

  
22
  Map::Map(const std::string map_path,
23
                   const float x_offset,
24
                   const float y_offset)
25
   {
26
      x_offset_ = x_offset;
27
      y_offset_ = y_offset;
28

  
29
      // Load Images
30
      base_path_ = QString(map_path.c_str());
31

  
32
      // Strip all double-slashes
33
      map_image_path_ = QString((map_path+".bmp").c_str());
34
      height_image_path_ = QString((map_path+"_height.bmp").c_str());
35

  
36
      // Check if images exist
37
      if(!file_exist(map_image_path_)) {
38
          ROS_INFO("Incorrect map path passed in");
39
          ROS_INFO("Should be of the form:");
40
          ROS_INFO("/path/to/map/map for map image of name:");
41
          ROS_INFO("   /path/to/map/map.bmp");
42
          assert(false);
43
      }
44

  
45
      if(!file_exist(height_image_path_)) {
46
          ROS_INFO("Incorrect map path passed in");
47
          ROS_INFO("Should be of the form:");
48
          ROS_INFO("/path/to/map/map for map image of name:");
49
          ROS_INFO("   /path/to/map/map_.bmp");
50
          assert(false);
51
      }
52

  
53
      // Find the correct dimensions
54
      // Check that the image format is correct
55
      map_image_ = new QImage(map_image_path_);
56
      height_image_ = new QImage(height_image_path_);
57

  
58
      // Check that images are in bounds
59
      int map_image_height = map_image_->height();
60
      int map_image_width = map_image_->width();
61

  
62
      int height_image_height = height_image_->height();
63
      int height_image_width = height_image_->width();
64

  
65
      if(height_image_height != map_image_height) {
66
          ROS_INFO("Map image height != height image height");
67
          assert(false);
68
      }
69

  
70
      if(height_image_width != map_image_width) {
71
          ROS_INFO("Map image width != height image width");
72
          assert(false);
73
      }
74

  
75
      map_pixel_height_ = map_image_height;
76
      map_pixel_width_= map_image_width;
77

  
78
      ROS_INFO("Loading map with path '%s'",base_path_.toUtf8().constData());
79

  
80
   }
81

  
82
   Map::~Map()
83
   {
84
       delete map_image_;
85
       delete height_image_;
86
   }
87

  
88
   int Map::getMapPixelHeight()
89
   {
90
      return map_pixel_height_;
91
   }
92

  
93
   int Map::getMapPixelWidth()
94
   {
95
       return map_pixel_width_;
96
   }
97

  
98
   float Map::getTerrainHeight(float x, float y) {
99
       ROS_INFO("Unimplemented");
100
       assert(false);
101
   }
102

  
103
   float Map::getColor(float x, float y) {
104
       ROS_INFO("Unimplemented");
105
       assert(false);
106
   }
107

  
108
   const QImage Map::getMapImage() {
109
       return *map_image_;
110
   }
111

  
112
   const QImage Map::getHeightImage() {
113
       return *height_image_;
114
   }
115

  
116
   float Map::getXOffset() {
117
       return x_offset_;
118
   }
119

  
120
   float Map::getYOffset() {
121
       return y_offset_;
122
   }
123

  
124
}
125

  
buggymaps/src/buggymaps.h
1
#ifndef BUGGYMAPS_BUGGYMAPS_H
2
#define BUGGYMAPS_BUGGYMAPS_H
3

  
4
#include <QImage>
5

  
6
namespace buggymaps
7
{
8

  
9
class Map
10
{
11
 public:
12
  Map(const std::string map_path,
13
      const float x_offset,
14
      const float y_offset);
15

  
16
  ~Map();
17

  
18
  int getMapPixelHeight();
19
  int getMapPixelWidth();
20

  
21
  float getTerrainHeight(float x, float y);
22

  
23
  float getColor(float x, float y);
24

  
25

  
26

  
27
  const QImage getMapImage();
28
  const QImage getHeightImage();
29

  
30
  float getXOffset();
31
  float getYOffset();
32

  
33
 private:
34
  QImage* map_image_;
35
  QImage* height_image_;
36

  
37

  
38
  QString base_path_;
39
  QString map_image_path_;
40
  QString height_image_path_;
41

  
42
  int map_pixel_height_;
43
  int map_pixel_width_;
44

  
45
  float x_offset_;
46
  float y_offset_;
47
};
48

  
49
}
50
#endif
buggysim/CMakeLists.txt
12 12

  
13 13
add_message_files(DIRECTORY msg FILES 
14 14
                  Velocity.msg)
15
#                  Color.msg Pose.msg Velocity.msg)
15

  
16 16
add_service_files(DIRECTORY srv FILES
17 17
                  Kill.srv
18 18
                  SetPen.srv

Also available in: Unified diff