Commit 50309ace authored by Victor Lamoine's avatar Victor Lamoine

Improvements

parent db24572f
......@@ -2,39 +2,40 @@
#include <ros/ros.h>
#include <serial_temperatures/serialportreader.hpp>
using std::cout;
using std::cerr;
using std::endl;
int main(int argc, char *argv[])
{
ros::init(argc, argv, "serial_temperatures");
std::shared_ptr<ros::NodeHandle> nh(std::make_shared<ros::NodeHandle>("~"));
int data_per_line(1);
nh->getParam("data_per_line", data_per_line);
if (data_per_line < 1)
int count(1);
nh->getParam("count", count);
if (count < 1)
{
ROS_ERROR_STREAM("data_per_line cannot be < 1");
ROS_ERROR_STREAM("count cannot be < 1");
return 1;
}
ROS_INFO_STREAM("Data per line = " << data_per_line);
ROS_INFO_STREAM("Count = " << count);
std::string topic;
nh->getParam("topic", topic);
if (topic.empty())
{
ROS_ERROR_STREAM("topic param must be specified and not empty");
return 1;
}
ROS_INFO_STREAM("Topic = " << topic);
ros::AsyncSpinner s(2);
s.start();
std::shared_ptr<std::vector<ros::Publisher>> publishers;
publishers = std::make_shared<std::vector<ros::Publisher>>();
publishers->resize(data_per_line);
publishers->resize(count);
for (std::size_t i(0); i < publishers->size(); ++i)
publishers->at(i) = nh->advertise<std_msgs::Float32>(topic + std::to_string(i), 5);
QCoreApplication app(argc, argv);
QSerialPort *serial_port(new QSerialPort);
SerialPortReader *serial_port_reader(new SerialPortReader(serial_port, data_per_line));
SerialPortReader *serial_port_reader(new SerialPortReader(serial_port, count));
serial_port_reader->publishers_ = publishers;
serial_port_reader->nh_ = nh;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment