16 bool PFInterface::init(std::shared_ptr<HandleInfo> info, std::shared_ptr<ScanConfig> config,
17 std::shared_ptr<ScanParameters> params,
const std::string& topic,
const std::string& frame_id,
18 const uint16_t num_layers)
33 ROS_ERROR(
"Unable to communicate with device. Please check the IP address");
37 if (opi.protocol_name !=
"pfsdp")
43 if (!
handle_version(opi.version_major, opi.version_minor, opi.device_family, topic, frame_id, num_layers))
58 transport_ = std::make_unique<UDPTransport>(info->hostname, info->port);
61 ROS_ERROR(
"Unable to establish UDP connection");
71 transport_ = std::make_unique<TCPTransport>(info->hostname);
78 ROS_ERROR(
"Unable to establish TCP connection");
88 if (
info_->handle.empty())
90 ROS_ERROR(
"Could not acquire communication handle");
111 text =
"Uninitialized";
113 text =
"Initialized";
120 ROS_INFO(
"Device state changed to %s", text.c_str());
129 std::shared_ptr<std::condition_variable> net_cv,
bool& net_fail)
181 float feed_time = std::min(duration, 60.0
f) / 2.0f;
193 ROS_INFO(
"Shutting down pipeline!");
199 std::cout <<
"handling connection failure" << std::endl;
201 std::cout <<
"terminated" << std::endl;
204 std::cout <<
"trying to reconnect..." << std::endl;
205 std::this_thread::sleep_for(std::chrono::milliseconds(500));
211 const std::string& frame_id,
const uint16_t num_layers)
213 std::string expected_dev =
"";
214 if (device_family == 1 || device_family == 3 || device_family == 6)
216 expected_dev =
"R2000";
221 else if (device_family == 5 || device_family == 7)
223 expected_dev =
"R2300";
226 if (device_family == 5)
229 reader_ = std::shared_ptr<PFPacketReader>(
232 else if (device_family == 7)
247 if (product_name.find(expected_dev) != std::string::npos)
256 std::shared_ptr<std::condition_variable> net_cv,
bool& net_fail)
258 std::shared_ptr<Parser<PFPacket>> parser;
259 std::shared_ptr<Writer<PFPacket>> writer;
262 ROS_DEBUG(
"PacketType is: %s", packet_type.c_str());
263 if (packet_type ==
"A")
267 else if (packet_type ==
"B")
271 else if (packet_type ==
"C")
278 if (packet_type ==
"C1")