紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
小鱼 ROS 2 新书上线!点击链接查看, 新书配套视频点击链接查看。
提问前必看的发帖注意事项—— 提问前必看!不符合要求的问题拒绝回答!!
社区使用指南—如何添加标签修改密码
路径寻迹时,读取csv文件在rviz里面显示path失败
-
各位大佬,我想实现控制小车走一圈,记录下路径点,然后小车跟踪路径点走,在读取csv文件显示路径的时候,rviz会自己结束,下面是报错。本人基础比较差,希望各位大佬解答一下
[showpath-2] process has died [pid 14866, exit code -11, cmd /home/www/xul307a_ws/devel/lib/path_track/showpath __name:=showpath __log:=/home/www/.ros/log/ec073fd6-017e-11ed-a45a-d4548b799fd2/showpath-2.log]. log file: /home/www/.ros/log/ec073fd6-017e-11ed-a45a-d4548b799fd2/showpath-2*.log ================================================================================REQUIRED process [rviz-3] has died! process has finished cleanly log file: /home/www/.ros/log/ec073fd6-017e-11ed-a45a-d4548b799fd2/rviz-3*.log Initiating shutdown! ================================================================================
这是显示csv文件的代码
#include <ros/ros.h> #include <ros/console.h> #include <nav_msgs/Path.h> #include <std_msgs/String.h> #include <geometry_msgs/Quaternion.h> #include <geometry_msgs/PoseStamped.h> #include <iostream> #include <sstream> #include <fstream> #include <string> #include "path_track/waypoint.h" #include "path_track/Lane.h" using namespace std; string file_path ; vector<string> vp; int velocity; void readfile(const std::string path , vector<string> &pathdata) { std::ifstream infile; infile.open(path.c_str(),ios::in); while (!infile.eof()) { string linestr; getline(infile,linestr); if (!linestr.empty()) { pathdata.push_back(linestr); } } infile.close(); } int main(int argc, char *argv[]) { setlocale(LC_ALL, ""); ros::init(argc,argv,"showpath"); ros::NodeHandle nh; ros::param::get("/path",file_path); ros::param::get("/velocity",velocity); readfile(file_path, vp); ros::Publisher pub_Path = nh.advertise<nav_msgs::Path>("/pub_Path", 2000); ros::Publisher pub_waypoints = nh.advertise<path_track::Lane>("/base_waypoint", 2000); nav_msgs::Path path; geometry_msgs::PoseStamped pose; path_track::waypoint waypoints; path_track::Lane lane; path.header.frame_id = "camera_init"; path.header.stamp = ros::Time::now(); lane.header.frame_id = "camera_init"; lane.header.stamp = ros::Time::now(); waypoints.pose.header.frame_id = "camera_init"; waypoints.pose.header.stamp = ros::Time::now(); int i = 0; int data_size = vp.size(); ros::Rate r(10); while (ros::ok()) { pose.header.frame_id = "camera_init"; pose.header.stamp = ros::Time::now(); string data[7]; istringstream tmp(vp[i]); tmp>>data[0]>>data[1]>>data[2]>>data[3]>>data[4]>>data[5]>>data[6]; pose.pose.position.x = (data[0] == "" ? 0 : stod(data[0].c_str())); pose.pose.position.y = (data[1] == "" ? 0 : stod(data[1].c_str())); pose.pose.position.z = (data[2] == "" ? 0 : stod(data[2].c_str())); pose.pose.orientation.x = (data[3] == "" ? 0 : stod(data[3].c_str())); pose.pose.orientation.y = (data[4] == "" ? 0 : stod(data[4].c_str())); pose.pose.orientation.z = (data[5] == "" ? 0 : stod(data[5].c_str())); pose.pose.orientation.w = (data[6] == "" ? 1 : stod(data[6].c_str())); waypoints.pose.pose.position.x=stod(data[0].c_str()); waypoints.pose.pose.position.y=stod(data[1].c_str()); waypoints.pose.pose.position.z=stod(data[2].c_str()); waypoints.pose.pose.orientation.x=stod(data[3].c_str()); waypoints.pose.pose.orientation.y=stod(data[4].c_str()); waypoints.pose.pose.orientation.z=stod(data[5].c_str()); waypoints.pose.pose.orientation.w=stod(data[6].c_str()); waypoints.twist.twist.linear.x = velocity; path.poses.push_back(pose); lane.waypoints.push_back(waypoints); pub_Path.publish(path); pub_waypoints.publish(lane); i++; r.sleep(); ros::spinOnce(); } return 0; }
-
-
@小鱼 是运行launch时报错的,运行rviz是这样的。
<launch> <param name="path" value="$(find path_track)/data/path1.csv" /> <param name="velocity" value="1" /> <node pkg="path_track" type="showpath" name="showpath" output="screen"/> <!--<node pkg="path_track" type="waypoint_updater.py" name="waypoint_updater" />--> <node pkg="rviz" type="rviz" name="rviz" args="-d $(find path_track)/rviz/showpath2.rviz" required="true" /> </launch>
-
@小丑汪 在你的代码里把文件路径打出来,确认是否有正确的读取到了,一步步排查即可。