鱼香ROS社区
    • 版块
    • 最新
    • 未解决
    • 已解决
    • 群组
    • 注册
    • 登录
    紧急通知:禁止一切关于政治&VPN翻墙等话题,发现相关帖子会立马删除封号
    提问前必看的发帖注意事项: 社区问答规则(小鱼个人)更新 | 高质量帖子发布指南

    路径寻迹时,读取csv文件在rviz里面显示path失败

    已定时 已固定 已锁定 已移动 未解决
    综合问题
    ros nav
    2
    4
    598
    正在加载更多帖子
    • 从旧到新
    • 从新到旧
    • 最多赞同
    回复
    • 在新帖中回复
    登录后回复
    此主题已被删除。只有拥有主题管理权限的用户可以查看。
    • 小丑汪小
      WOW995
      最后由 小鱼 编辑

      各位大佬,我想实现控制小车走一圈,记录下路径点,然后小车跟踪路径点走,在读取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;
      }
      
      
      小鱼小 2 条回复 最后回复 回复 引用 0
      • 小鱼小
        小鱼 技术大佬 @小丑汪
        最后由 编辑

        @小丑汪 在 路径寻迹时,读取csv文件在rviz里面显示path失败 中说:

        下面是报错

        这个是运行什么指令报的错

        新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

        小丑汪小 1 条回复 最后回复 回复 引用 0
        • 小丑汪小
          WOW995 @小鱼
          最后由 编辑

          @小鱼 是运行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>
          

          12.jpg

          1 条回复 最后回复 回复 引用 0
          • 小鱼小
            小鱼 技术大佬 @小丑汪
            最后由 编辑

            @小丑汪 在你的代码里把文件路径打出来,确认是否有正确的读取到了,一步步排查即可。

            新书配套视频:https://www.bilibili.com/video/BV1GW42197Ck/

            1 条回复 最后回复 回复 引用 0
            • 第一个帖子
              最后一个帖子
            皖ICP备16016415号-7
            Powered by NodeBB | 鱼香ROS