How to solve different ros::Time error message
I have a total of N. 7 .csv
files. Those files are the result of N.7 sensors mounted on an underwater system. After packing both custom and standard messages according to available documentation and playing them in a test.bag
file I am able to see the majority of them being broadcasted.
Every file is composed of a different type of column but there is the same column in every file, which is timestamp
.
The procedure
I am showing here N.3 print screen to replicate the problem.
The first file is composed of N.4 columns as it is possible to see below:
The second file is composed of N.3 columns as it is possible to see below:
The third file I am showing is composed of 18 columns but I am showing only the last columns (that has the timestamp) as it is possible to see below:
The way I am packing all the customized and non-customized ROS
messages is shown below, and it is done in the same way for all the N.7 files. So for brevity I am only including one that is related to the first file shown above. Here is the most important part of the code:
keller_reader.h
#include "csv.h"
#include <string>
#include "ros_float/pressure.h"
#include "ros_float/depth.h"
#include "ros_float/temperature.h"
struct KELLER_DATA
{
unsigned long timestamp;
double depth;
double temperature;
double pressure;
};
class Keller_reader
{
public:
Keller_reader(std::string filename);
bool nextLine();
KELLER_DATA keller_data;
sensor_msgs::FluidPressure pressureMsg;
ros_float::pressure pMsg;
ros_float::temperature tMsg;
ros_float::depth dMsg;
private:
io::CSVReader<4> keller_reader;
unsigned int msgNumKeller;
void packPressureMsg();
// Custom Pressure Message
void packCustom_TemperatureMsg();
void packCustom_DepthMsg();
};
keller_reader.cpp
#include "keller_reader.h"
Keller_reader::Keller_reader(std::string filename):
keller_reader(filename)
{
msgNumKeller = 0;
keller_reader.read_header(io::ignore_extra_column,
"timestamp", "depth", "temp","pressure");
}
bool Keller_reader::nextLine()
{
if(keller_reader.read_row(keller_data.timestamp, keller_data.depth,
keller_data.temperature, keller_data.pressure))
{
packPressureMsg();
packCustom_TemperatureMsg();
packCustom_DepthMsg();
msgNumKeller++;
return true;
}
else
{
return false;
}
}
void Keller_reader::packPressureMsg()
{
double doubleTime = double(keller_data.timestamp)/1e6;
ros::Time stamp(doubleTime);
pMsg.header.stamp = stamp;
pMsg.header.frame_id = "/pressure";
pMsg.header.seq = msgNumKeller;
pMsg.fluid_pressure = keller_data.pressure;
}
void Keller_reader::packCustom_TemperatureMsg()
{
// same procedure as above
}
void Keller_reader::packCustom_DepthMsg()
{
// same procedure as above
}
Notice that the timestamp is treated in the same way in all files so that can be brought to a standard readable ROS
time:
double doubleTime = double(keller_data.timestamp)/1e6;
ros::Time stamp(doubleTime);
Because remember from above that what I have in the .csv
file is this:
The Problem
This approach works well for all N.6 files. However when I do the same with the last file I have very different errors. The most important part of the code is below:
usbl_reader.h
struct USBL_DATA
{
int prop_time;
double accuracy;
double e;
unsigned long ctime;
double h_reader;
int remote_id;
int rssi;
double n;
double p;
double depthUSBL;
double r;
double u;
unsigned long mtime;
double xPosition;
double yPosition;
double zPosition;
int integrity;
unsigned long timestamp;
};
class USBL_reader
{
public:
USBL_reader(std::string filename);
bool nextLine();
USBL_DATA ...