Hi
I am using ubuntu 16.04 and ros kinetic
I created a package for a subscriber node(start_goal_generator.cpp), this node must get the published topic "map" from map_server node
i tried to build the workspace with catkin_make, the output is:
Base path: /home/evadro/Desktop/Eman/ros_workspace
Source space: /home/evadro/Desktop/Eman/ros_workspace/src
Build space: /home/evadro/Desktop/Eman/ros_workspace/build
Devel space: /home/evadro/Desktop/Eman/ros_workspace/devel
Install space: /home/evadro/Desktop/Eman/ros_workspace/install
####
#### Running command: "make cmake_check_build_system" in "/home/evadro/Desktop/Eman/ros_workspace/build"
####
-- Using CATKIN_DEVEL_PREFIX: /home/evadro/Desktop/Eman/ros_workspace/devel
-- Using CMAKE_PREFIX_PATH: /home/evadro/Desktop/Eman/ros_workspace/devel;/home/evadro/catkin_ws/devel;/opt/ros/kinetic
-- This workspace overlays: /home/evadro/Desktop/Eman/ros_workspace/devel;/home/evadro/catkin_ws/devel;/opt/ros/kinetic
-- Found PythonInterp: /usr/bin/python2 (found suitable version "2.7.12", minimum required is "2")
-- Using PYTHON_EXECUTABLE: /usr/bin/python2
-- Using Debian Python package layout
-- Using empy: /usr/bin/empy
-- Using CATKIN_ENABLE_TESTING: ON
-- Call enable_testing()
-- Using CATKIN_TEST_RESULTS_DIR: /home/evadro/Desktop/Eman/ros_workspace/build/test_results
-- Found gtest sources under '/usr/src/gmock': gtests will be built
-- Found gmock sources under '/usr/src/gmock': gmock will be built
-- Found PythonInterp: /usr/bin/python2 (found version "2.7.12")
-- Using Python nosetests: /usr/bin/nosetests-2.7
-- catkin 0.7.29
-- BUILD_SHARED_LIBS is on
-- BUILD_SHARED_LIBS is on
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- ~~ traversing 6 packages in topological order:
-- ~~ - rosbot_ekf
-- ~~ - start_goal_generator
-- ~~ - rplidar_ros
-- ~~ - rosbot_navigation
-- ~~ - rosbot_description
-- ~~ - rosbot_gazebo
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-- +++ processing catkin package: 'rosbot_ekf'
-- ==> add_subdirectory(rosbot_ekf)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- rosbot_ekf: 1 messages, 1 services
-- +++ processing catkin package: 'start_goal_generator'
-- ==> add_subdirectory(start_goal_generator)
-- Using these message generators: gencpp;geneus;genlisp;gennodejs;genpy
-- +++ processing catkin package: 'rplidar_ros'
-- ==> add_subdirectory(rplidar_ros)
-- +++ processing catkin package: 'rosbot_navigation'
-- ==> add_subdirectory(rosbot_description/src/rosbot_navigation)
-- +++ processing catkin package: 'rosbot_description'
-- ==> add_subdirectory(rosbot_description/src/rosbot_description)
-- +++ processing catkin package: 'rosbot_gazebo'
-- ==> add_subdirectory(rosbot_description/src/rosbot_gazebo)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/evadro/Desktop/Eman/ros_workspace/build
####
#### Running command: "make -j24 -l24" in "/home/evadro/Desktop/Eman/ros_workspace/build"
####
[ 0%] Built target actionlib_generate_messages_nodejs
[ 0%] Built target geometry_msgs_generate_messages_py
[ 0%] Built target tf2_msgs_generate_messages_lisp
[ 0%] Built target tf2_msgs_generate_messages_nodejs
[ 0%] Built target std_msgs_generate_messages_py
[ 0%] Built target geometry_msgs_generate_messages_nodejs
[ 0%] Built target std_msgs_generate_messages_nodejs
[ 0%] Built target geometry_msgs_generate_messages_lisp
[ 0%] Built target tf2_msgs_generate_messages_eus
[ 0%] Built target roscpp_generate_messages_lisp
[ 0%] Built target std_msgs_generate_messages_lisp
[ 0%] Built target std_msgs_generate_messages_eus
[ 0%] Built target _catkin_empty_exported_target
[ 0%] Built target nav_msgs_generate_messages_cpp
[ 0%] Built target nav_msgs_generate_messages_eus
[ 0%] Built target roscpp_generate_messages_nodejs
[ 0%] Built target roscpp_generate_messages_eus
[ 0%] Built target rosgraph_msgs_generate_messages_lisp
[ 0%] Built target tf_generate_messages_eus
[ 0%] Built target rosgraph_msgs_generate_messages_nodejs
[ 0%] Built target geometry_msgs_generate_messages_cpp
[ 0%] Built target nav_msgs_generate_messages_py
[ 0%] Built target geometry_msgs_generate_messages_eus
[ 0%] Built target roscpp_generate_messages_cpp
[ 0%] Built target sensor_msgs_generate_messages_nodejs
[ 0%] Built target tf2_msgs_generate_messages_cpp
[ 0%] Built target rosgraph_msgs_generate_messages_cpp
[ 0%] Built target actionlib_msgs_generate_messages_py
[ 0%] Built target std_msgs_generate_messages_cpp
[ 0%] Built target actionlib_generate_messages_eus
[ 0%] Built target tf_generate_messages_cpp
[ 0%] Built target rosgraph_msgs_generate_messages_eus
[ 0%] Built target nav_msgs_generate_messages_lisp
[ 0%] Built target actionlib_msgs_generate_messages_lisp
[ 0%] Built target actionlib_generate_messages_py
[ 0%] Built target nav_msgs_generate_messages_nodejs
[ 0%] Built target tf2_msgs_generate_messages_py
[ 0%] Built target actionlib_msgs_generate_messages_nodejs
[ 0%] Built target sensor_msgs_generate_messages_cpp
[ 0%] Built target rosgraph_msgs_generate_messages_py
[ 0%] Built target roscpp_generate_messages_py
[ 0%] Built target tf_generate_messages_nodejs
[ 0%] Built target tf_generate_messages_py
[ 0%] Built target tf_generate_messages_lisp
[ 0%] Built target actionlib_generate_messages_cpp
[ 0%] Built target sensor_msgs_generate_messages_lisp
[ 0%] Built target actionlib_generate_messages_lisp
[ 0%] Built target actionlib_msgs_generate_messages_eus
[ 0%] Built target sensor_msgs_generate_messages_py
[ 0%] Built target actionlib_msgs_generate_messages_cpp
[ 0%] Built target sensor_msgs_generate_messages_eus
[ 0%] Built target _rosbot_ekf_generate_messages_check_deps_Imu
[ 6%] Built target start_goal_generator_node
[ 6%] Built target _rosbot_ekf_generate_messages_check_deps_Configuration
[ 13%] Built target rplidarNodeClient
[ 36%] Built target rplidarNode
[ 63%] Built target rosbot_ekf_generate_messages_py
[ 60%] Built target rosbot_ekf_generate_messages_nodejs
[ 63%] Built target rosbot_ekf_generate_messages_lisp
[ 80%] Built target rosbot_ekf_generate_messages_cpp
[ 80%] Built target rosbot_ekf_generate_messages_eus
[ 80%] Built target rosbot_ekf_generate_messages
[ 86%] Built target msgs_conversion
[ 93%] Built target move_base_ws2812b_example
[100%] Built target cmd_vel_ws2812b_example
when I try to compile the node: g++ start_goal_generator.cpp
it gives error:
start_goal_generator.cpp:1:10: fatal error: ros/ros.h: No such file or directory #include "ros/ros.h"
compilation terminated.
This is start_goal_generator.cpp
#include "ros/ros.h"
#include "nav_msgs/OccupancyGrid.h"
#include "std_msgs/Header.h"
#include "nav_msgs/MapMetaData.h"
#include<iostream>
#include <fstream>
#include <random>
#include <unistd.h>
using namespace std;
std::default_random_engine generator;
unsigned int sleep(unsigned int seconds);
//#include "quadtree.h"
ros::Publisher map_pub;
//////////////////////////////////////////////////////////////////////////
double calculateDistance(int sRow, int sColumn, int gRow, int gColumn)
{
double dist;
dist= sqrt((pow((sRow - gRow),2))+pow((sColumn - gColumn),2));
return dist;
}// end function calculateDistance
///////////////////////////////////////////////////////////////////////
void mapCallback(const nav_msgs::OccupancyGrid::ConstPtr& msg)
{
std_msgs::Header header = msg->header;
nav_msgs::MapMetaData info = msg->info;
ROS_INFO("Got map %d %d", info.width, info.height);
int width = info.width;
int height = info.height;
int startCell=0;
int goalCell=0;
long cellID=-1;
int startRow = 0;
int startColumn = 0;
int goalRow = 0;
int goalColumn = 0;
int max_value = height * width;
int numberOfScenarios = 30;
srand ( time(NULL) );
sleep(1.0);
for(int scenario=1; scenario <= numberOfScenarios; scenario++)
{
// choose random start
do{
cellID = (rand() % max_value);
startCell = cellID;
}while(msg->data[startCell] != 0);
startRow = cellID/width;
startColumn = cellID%width;
// choose random goal
double thresholdDistance= 8.0; // 8.0 meter
do{
cellID = (rand() % max_value);
goalCell = cellID;
goalRow= cellID/width;
goalColumn=cellID%width;
}while ((goalCell == startCell) || (msg->data[goalCell] != 0) || (calculateDistance(startRow,startColumn,goalRow,goalColumn) < thresholdDistance));
// write start and goal to text file
// create text file
ofstream scenarios_textfile ("rosMapRandomScenarios.txt", ios::app);
// write startCell and goalCell
scenarios_textfile <<startCell<<" "<< goalCell<<endl;
}// end for each scenario
}// end function mapCallback
int main(int argc, char **argv)
{
ros::init(argc, argv, "grid");
ros::NodeHandle n;
//map_pub = n.advertise<nav_msgs::OccupancyGrid>("map_out",10);
ros::Subscriber map_sub = n.subscribe("map",10,mapCallback);
ros::spin();
return 0;
}// end main
This is package.xml
<?xml version="1.0"?>
<package format="2">
<name>start_goal_generator</name>
<version>0.0.0</version>
<description>The start_goal_generator package generates a set of start and goal scenarios</description>
<maintainer email="[email protected]">evadro</maintainer>
<license>TODO</license>
<buildtool_depend>catkin</buildtool_depend>
<build_depend>roscpp</build_depend>
<build_depend>rospy</build_depend>
<build_depend>std_msgs</build_depend>
<build_depend>nav_msgs</build_depend>
<build_export_depend>roscpp</build_export_depend>
<build_export_depend>rospy</build_export_depend>
<build_export_depend>std_msgs</build_export_depend>
<build_export_depend>nav_msgs</build_export_depend>
<exec_depend>roscpp</exec_depend>
<exec_depend>rospy</exec_depend>
<exec_depend>std_msgs</exec_depend>
<exec_depend>nav_msgs</exec_depend>
<!-- The export tag contains other, unspecified, tags -->
<export>
<!-- Other tools can request additional information be placed here -->
</export>
</package>
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(start_goal_generator)
## Compile as C++11, supported in ROS Kinetic and newer
## add_compile_options(-std=c++11)
find_package(catkin REQUIRED COMPONENTS
roscpp
rospy
std_msgs
nav_msgs
)
find_package(Boost REQUIRED COMPONENTS system)
catkin_package(
INCLUDE_DIRS include
LIBRARIES start_goal_generator
CATKIN_DEPENDS roscpp rospy std_msgs nav_msgs
)
include_directories(include ${catkin_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS})
add_executable(start_goal_generator_node
src/start_goal_generator.cpp
)
target_link_libraries(start_goal_generator_node
${catkin_LIBRARIES}
${Boost_LIBRARIES}
)
Thanks,,,
Originally posted by Eman.m on ROS Answers with karma: 65 on 2021-04-22
Post score: 0