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

Seyond #167

Merged
merged 3 commits into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
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
33 changes: 31 additions & 2 deletions nebula_common/include/nebula_common/seyond/seyond_common.hpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef NEBULA_SEYOND_COMMON_H

Check warning on line 1 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (SEYOND)
#define NEBULA_SEYOND_COMMON_H

Check warning on line 2 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (SEYOND)

#include "nebula_common/nebula_common.hpp"
#include "nebula_common/nebula_status.hpp"
Expand All @@ -13,8 +13,8 @@
{
namespace drivers
{
/// @brief struct for Seyond sensor configuration

Check warning on line 16 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (Seyond)
struct SeyondSensorConfiguration : public LidarConfigurationBase

Check warning on line 17 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (Seyond)
{
uint16_t gnss_port{};
double scan_phase{};
Expand All @@ -27,11 +27,11 @@
PtpTransportType ptp_transport_type;
PtpSwitchType ptp_switch_type;
};
/// @brief Convert SeyondSensorConfiguration to string (Overloading the << operator)

Check warning on line 30 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (Seyond)
/// @param os
/// @param arg
/// @return stream
inline std::ostream & operator<<(std::ostream & os, SeyondSensorConfiguration const & arg)

Check warning on line 34 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (Seyond)
{
os << (LidarConfigurationBase)(arg) << ", GnssPort: " << arg.gnss_port
<< ", ScanPhase:" << arg.scan_phase << ", RotationSpeed:" << arg.rotation_speed
Expand All @@ -43,7 +43,7 @@
return os;
}

struct SeyondCalibrationConfigurationBase : public CalibrationConfigurationBase

Check warning on line 46 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (Seyond)
{

};
Expand Down Expand Up @@ -80,6 +80,16 @@
inline ReturnMode ReturnModeFromStringSeyond(
const std::string & return_mode, const SensorModel & sensor_model)
{
switch (sensor_model) {
case SensorModel::SEYOND_FALCON_KINETIC:

Check warning on line 84 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (SEYOND)
case SensorModel::SEYOND_ROBIN_W:

Check warning on line 85 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (SEYOND)
if (return_mode == "Strongest") return ReturnMode::STRONGEST;
if (return_mode == "Dual") return ReturnMode::DUAL;
if (return_mode == "DualStrongestLast") return ReturnMode::DUAL_STRONGEST_LAST;
break;
default:
break;
}
return ReturnMode::UNKNOWN;
}

Expand All @@ -89,6 +99,16 @@
/// @return Corresponding ReturnMode
inline ReturnMode ReturnModeFromIntSeyond(const int return_mode, const SensorModel & sensor_model)
{
switch (sensor_model) {
case SensorModel::SEYOND_FALCON_KINETIC:

Check warning on line 103 in nebula_common/include/nebula_common/seyond/seyond_common.hpp

View workflow job for this annotation

GitHub Actions / spell-check-differential

Unknown word (SEYOND)
case SensorModel::SEYOND_ROBIN_W:
if (return_mode == 1) return ReturnMode::STRONGEST;
if (return_mode == 2) return ReturnMode::DUAL;
if (return_mode == 3) return ReturnMode::DUAL_STRONGEST_LAST;
break;
default:
break;
}
return ReturnMode::UNKNOWN;
}

Expand All @@ -98,11 +118,20 @@
/// @return Corresponding return mode number for the hardware
inline int IntFromReturnModeSeyond(const ReturnMode return_mode, const SensorModel & sensor_model)
{

switch (sensor_model) {
case SensorModel::SEYOND_FALCON_KINETIC:
case SensorModel::SEYOND_ROBIN_W:
if (return_mode == ReturnMode::STRONGEST) return 1;
if (return_mode == ReturnMode::DUAL) return 2;
if (return_mode == ReturnMode::DUAL_STRONGEST_LAST) return 3;
break;
default:
break;
}
return -1;
}

} // namespace drivers
} // namespace nebula

#endif // NEBULA_SEYOND_COMMON_H
#endif // NEBULA_SEYOND_COMMON_H
Original file line number Diff line number Diff line change
Expand Up @@ -27,45 +27,60 @@
#include <boost/property_tree/ptree.hpp>

#include <memory>
#include <mutex>
#include <vector>

namespace nebula
{
namespace drivers
{
constexpr uint16_t SeyondTcpCommandPort = 8001;
constexpr uint16_t SeyondHttpCommandPort = 8010;
/// @brief Hardware interface of seyond driver
class SeyondHwInterface
{
private:
std::unique_ptr<::drivers::common::IoContext> cloud_io_context_;
std::shared_ptr<boost::asio::io_context> m_owned_ctx;
std::unique_ptr<::drivers::udp_driver::UdpDriver> cloud_udp_driver_;
std::shared_ptr<const SeyondSensorConfiguration> sensor_configuration_;
std::function<void(std::vector<uint8_t> & buffer)>
cloud_packet_callback_; /**This function pointer is called when the scan is complete*/

int prev_phase_{};
int target_model_no;
std::shared_ptr<boost::asio::io_context> m_owned_ctx_;
std::unique_ptr<::drivers::tcp_driver::TcpDriver> command_tcp_driver_;

std::shared_ptr<rclcpp::Logger> parent_node_logger_;

/// @brief Printing the string to RCLCPP_INFO_STREAM
/// @param info Target string
void PrintInfo(std::string info);

/// @brief Printing the string to RCLCPP_ERROR_STREAM
/// @param error Target string
void PrintError(std::string error);

/// @brief Printing the string to RCLCPP_DEBUG_STREAM
/// @param debug Target string
void PrintDebug(std::string debug);

/// @brief Send TCP command to the device and return its response as string
/// @param commad payload of the command to be sent
/// @return string response from the device
std::string SendCommand(std::string commad);

/// @brief Start UDP stream from the device
Status StartUdpStreaming();

public:
/// @brief Constructor
SeyondHwInterface();

/// @brief Destructor
~SeyondHwInterface();

/// @brief Initializing tcp_driver for TCP communication
/// @return Resulting status
Status InitializeTcpDriver();

/// @brief Callback function to receive the Cloud Packet data from the UDP Driver
/// @param buffer Buffer containing the data received from the UDP socket
void ReceiveSensorPacketCallback(std::vector<uint8_t> & buffer);
Expand Down Expand Up @@ -93,11 +108,11 @@ class SeyondHwInterface
/// @param sensor_configuration SensorConfiguration for this interface
/// @return Resulting status
Status SetSensorConfiguration(
std::shared_ptr<const SensorConfigurationBase> sensor_configuration);
const std::shared_ptr<const SensorConfigurationBase>& sensor_configuration);

/// @brief Set target model number
/// @param model Model number
void SetTargetModel(int model);
// /// @brief Set target model number
// /// @param model Model number
// void SetTargetModel(nebula::drivers::SensorModel model);

/// @brief Registering callback for NebulaPackets
/// @param scan_callback Callback function
Expand All @@ -107,6 +122,24 @@ class SeyondHwInterface
/// @brief Setting rclcpp::Logger
/// @param node Logger
void SetLogger(std::shared_ptr<rclcpp::Logger> logger);

/// @brief Display common information acquired from sensor
void DisplayCommonVersion();

/// @brief Setting device return mode
/// @param return_mode The mode of return
/// @return Resulting status
Status SetReturnMode(int return_mode);


/// @brief Setting PTP profile
/// @param profile profile to be set
/// @return Resulting status
Status SetPtpMode(PtpProfile profile);

/// @brief validate the current settings then set them
/// @return Resulting status
Status CheckAndSetConfig();
};
} // namespace drivers
} // namespace nebula
Expand Down
Loading
Loading