Skip to content

Commit 9c40316

Browse files
committed
Add mapping and planner nodes
0 parents  commit 9c40316

File tree

19 files changed

+1123
-0
lines changed

19 files changed

+1123
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
*__pycache__
2+
*.idea/
3+
*/cmake-build-debug/

mapping/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(mapping)
3+
4+
set(CMAKE_CXX_FLAGS "-std=c++17 -fPIC")
5+
6+
find_package(catkin REQUIRED COMPONENTS
7+
roscpp
8+
std_msgs
9+
sensor_msgs
10+
geometry_msgs
11+
nav_msgs
12+
message_generation
13+
)
14+
15+
find_package(OpenCV REQUIRED)
16+
17+
catkin_package(CATKIN_DEPENDS
18+
roscpp
19+
std_msgs
20+
sensor_msgs
21+
geometry_msgs
22+
nav_msgs
23+
message_runtime
24+
)
25+
26+
include_directories(
27+
include
28+
${catkin_INCLUDE_DIRS}
29+
${OpenCV_INCLUDE_DIRS}
30+
)
31+
32+
add_executable(mapping_node src/mapping_node.cpp src/Map.cpp)
33+
target_link_libraries(mapping_node ${catkin_LIBRARIES} ${OpenCV_LIBS})
34+
add_dependencies(mapping_node ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})

mapping/include/mapping/Map.h

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
//
2+
// Created by naivehobo on 11/9/19.
3+
//
4+
5+
#ifndef MAPPING_MAP_H
6+
#define MAPPING_MAP_H
7+
8+
#include <ros/ros.h>
9+
10+
#include <nav_msgs/OccupancyGrid.h>
11+
#include <geometry_msgs/PoseStamped.h>
12+
#include <geometry_msgs/Pose2D.h>
13+
14+
#include <opencv2/core/core.hpp>
15+
#include <opencv2/imgproc/imgproc.hpp>
16+
#include <opencv2/highgui/highgui.hpp>
17+
18+
19+
enum BrushState {
20+
READY,
21+
ACTIVE,
22+
DELETE,
23+
MAP,
24+
POSE,
25+
GOAL
26+
};
27+
28+
struct Brush {
29+
std::string window;
30+
cv::Mat *canvas;
31+
cv::Scalar *color;
32+
cv::Point pos;
33+
int width;
34+
BrushState state;
35+
};
36+
37+
38+
class Map {
39+
40+
public:
41+
42+
Map();
43+
~Map();
44+
45+
void markObstacles();
46+
47+
void markStartingPosition();
48+
49+
void markGoal();
50+
51+
void markWaypoint(int x, int y);
52+
53+
private:
54+
55+
void publishMap();
56+
void publishGoal();
57+
void publishPose();
58+
59+
void goalCallback(const geometry_msgs::PoseStamped::ConstPtr &goal);
60+
61+
static void onMouse(int event, int x, int y, int flags, void* ptr);
62+
63+
ros::NodeHandle nh_;
64+
ros::NodeHandle private_nh_;
65+
66+
ros::Publisher map_pub_;
67+
ros::Publisher goal_pub_;
68+
ros::Publisher pose_pub_;
69+
70+
ros::Subscriber goal_sub_;
71+
72+
std::string map_topic_;
73+
std::string pose_topic_;
74+
std::string goal_topic_;
75+
76+
std::string save_map_;
77+
78+
cv::Mat map_;
79+
std::string window_;
80+
81+
geometry_msgs::Pose2D pose_;
82+
geometry_msgs::Pose2D goal_;
83+
84+
int height_;
85+
int width_;
86+
float resolution_;
87+
};
88+
89+
#endif //MAPPING_MAP_H

mapping/launch/mapping_node.launch

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<launch>
2+
<node type="mapping_node" name="mapping_node" pkg="mapping" output="screen">
3+
<param name="map_topic" value="/map"/>
4+
<param name="goal_topic" value="/goal"/>
5+
<param name="pose_topic" value="/pose"/>
6+
<param name="height" value="500"/>
7+
<param name="width" value="500"/>
8+
<param name="resolution" value="0.05"/>
9+
<!--<param name="save_map" value=""/>-->
10+
<!--<param name="load_map" value=""/>-->
11+
</node>
12+
</launch>

mapping/maps/map.png

7.25 KB
Loading

mapping/package.xml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0"?>
2+
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
3+
4+
<package format="2">
5+
<name>mapping</name>
6+
<version>0.0.0</version>
7+
<description>
8+
Mapping node to place obstacles in the environment and define starting position
9+
</description>
10+
<maintainer email="[email protected]">Sarthak Mittal</maintainer>
11+
<license>BSD</license>
12+
13+
<buildtool_depend>catkin</buildtool_depend>
14+
15+
<build_depend>message_generation</build_depend>
16+
17+
<depend>roscpp</depend>
18+
<depend>std_msgs</depend>
19+
<depend>sensor_msgs</depend>
20+
<depend>geometry_msgs</depend>
21+
<depend>nav_msgs</depend>
22+
23+
<exec_depend>message_runtime</exec_depend>
24+
25+
</package>

0 commit comments

Comments
 (0)