Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gazebo sdf find csv file #22

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/livox_points_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include <gazebo/transport/Node.hh>
#include "livox_laser_simulation/csv_reader.hpp"
#include "livox_laser_simulation/livox_ode_multiray_shape.h"
#include <sdf/sdf_config.h>

namespace gazebo {

Expand All @@ -39,12 +40,21 @@ void convertDataToRotateInfo(const std::vector<std::vector<double>> &datas, std:

void LivoxPointsPlugin::Load(gazebo::sensors::SensorPtr _parent, sdf::ElementPtr sdf) {
std::vector<std::vector<double>> datas;
std::string file_name = sdf->Get<std::string>("csv_file_name");
ROS_INFO_STREAM("load csv file name:" << file_name);
if (!CsvReader::ReadCsvFile(file_name, datas)) {
ROS_INFO_STREAM("cannot get csv file!" << file_name << "will return !");
std::string csv_file_name = sdf->Get<std::string>("csv_file_name");
{
ROS_INFO_STREAM("load csv file name:" << csv_file_name);
}
std::string resolved_csv_file_name = sdf::findFile(csv_file_name, true, true);
if (resolved_csv_file_name.empty())
{
ROS_INFO_STREAM("cannot resolve csv file!" << csv_file_name << "will return !");
return;
}
if (!CsvReader::ReadCsvFile(resolved_csv_file_name, datas)) {
ROS_INFO_STREAM("cannot get csv file!" << resolved_csv_file_name << "will return !");
return;
}

sdfPtr = sdf;
auto rayElem = sdfPtr->GetElement("ray");
auto scanElem = rayElem->GetElement("scan");
Expand Down