赞
踩
wget -P ~/Downloads https://storage.googleapis.com/cartographer-public-data/bags/mir/landmarks_demo_uncalibrated.bag
- cd car2_ws/src
- git clone https://github.com/googlecartographer/cartographer_mir.git
- catkin_make_isolated --install --use-ninja
- source install_isolated/setup.bash
roslaunch cartographer_mir offline_mir_100_rviz.launch bag_filenames:=${HOME}/Downloads/landmarks_demo_uncalibrated.bag
mkdir -p pl/src
catkin_make
- cd src
- catkin_create_pkg pub_landmark roscpp rospy std_msgs
将~/car2_ws/install_isolated/include/cartographer_ros_msgs下的两个配置文件放入~/pl/src/pub_landmark/include/pub_landmark下
功能包下新建 msg 目录,添加文件 LandmarkEntry.msg、LandmarkList.h
- <build_depend>message_generation</build_depend>
- <exec_depend>message_runtime</exec_depend>
- #include "ros/ros.h"
- #include "pub_landmark/LandmarkList.h"
- #include "pub_landmark/LandmarkEntry.h"
- #include "geometry_msgs/Pose.h"
- #include "std_msgs/String.h"
- #include "std_msgs/Header.h"
-
- int main(int argc, char *argv[])
- {
- ros::init(argc, argv, "pub_landmark");
- ros::NodeHandle nh;
- ros::NodeHandle n("~");
-
- ros::Publisher landmark_pub = n.advertise<cartographer_ros_msgs::LandmarkList>("landmark", 10);
-
- cartographer_ros_msgs::LandmarkList landmark_0;
-
- ros::Rate loop_rate(10);
- int count=0;
- while (ros::ok())
- {
- landmark_0.header.stamp = ros::Time::now();
- landmark_0.header.frame_id = "base_link";
- landmark_0.landmarks.resize(10);
-
- for(int t=0;t<10;t++)
- {
- std::stringstream ss;
- ss << t;//"landmark_" ;//<< count/ << "_" t;
-
- landmark_0.landmarks[t].id = ss.str();
- landmark_0.landmarks[t].tracking_from_landmark_transform.position.x = 1.0*t;
- landmark_0.landmarks[t].tracking_from_landmark_transform.position.y = 2.0*t;
- landmark_0.landmarks[t].tracking_from_landmark_transform.position.z = 3.0*t;
- landmark_0.landmarks[t].tracking_from_landmark_transform.orientation.w = 1.0*t;
- landmark_0.landmarks[t].tracking_from_landmark_transform.orientation.x = 0.0*t;
- landmark_0.landmarks[t].tracking_from_landmark_transform.orientation.y = 0.0*t;
- landmark_0.landmarks[t].tracking_from_landmark_transform.orientation.z = 0.0*t;
- landmark_0.landmarks[t].translation_weight = 1.0*t;
- landmark_0.landmarks[t].rotation_weight = 2.0*t;
- }
-
- landmark_pub.publish(landmark_0);
- ROS_INFO("%d", count);
-
- loop_rate.sleep();
- count++;
- }
-
- return 0;
- }
-
- cmake_minimum_required(VERSION 3.0.2)
- project(pub_landmark)
-
- find_package(catkin REQUIRED COMPONENTS
- roscpp
- rospy
- std_msgs
- message_generation
- sensor_msgs
- )
-
-
- add_message_files(
- FILES
- LandmarkEntry.msg
- LandmarkList.msg
- )
-
-
- generate_messages(
- DEPENDENCIES
- std_msgs
- sensor_msgs
- geometry_msgs
- )
-
- catkin_package(
- # INCLUDE_DIRS include
- # LIBRARIES pub_landmark
- CATKIN_DEPENDS roscpp rospy std_msgs message_runtime
- # DEPENDS system_lib
- )
-
- include_directories(
- include
- ${catkin_INCLUDE_DIRS}
- )
-
-
-
- add_executable(pub src/pub_landmark.cpp)
-
-
- add_dependencies(pub ${${PROJECT_NAME}_EXPORTED_TARGETS} ${catkin_EXPORTED_TARGETS})
-
-
- target_link_libraries(pub
- ${catkin_LIBRARIES}
- )
-
-
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。