debug 18
This commit is contained in:
parent
6821837465
commit
bd147b7b58
@ -1,71 +1,71 @@
|
||||
#ifndef _AG_Pbox_HPP_
|
||||
#define _AG_Pbox_HPP_
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <cstdlib>
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
#include <cstring>
|
||||
#include <cmath>
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/time.h>
|
||||
#include <netinet/in.h>
|
||||
#include <serial/serial.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <cstring>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include "protocol_asensing.h"
|
||||
#include "TinyLog.h"
|
||||
#include "protocol_asensing.h"
|
||||
#include "rclcpp/rclcpp.hpp"
|
||||
using namespace std;
|
||||
using namespace std::chrono_literals;
|
||||
using namespace serial;
|
||||
|
||||
|
||||
#define UART_PORT "/dev/ttyUSB0"
|
||||
#define UART_BAUDRATE (115200)
|
||||
#define UART_PORT "/dev/ttyTHS1"
|
||||
#define UART_BAUDRATE (115200)
|
||||
|
||||
class AGPbox : public rclcpp::Node
|
||||
{
|
||||
public:
|
||||
AGPbox();
|
||||
void init_pbox_node();
|
||||
private:
|
||||
void timer_callback();
|
||||
void openSerialPort();
|
||||
void readSerialPort();
|
||||
public:
|
||||
AGPbox();
|
||||
void init_pbox_node();
|
||||
|
||||
void bindUdp();
|
||||
void readUdp();
|
||||
private:
|
||||
/* serial port info */
|
||||
serial::Serial imu_ser;
|
||||
std::string m_port;
|
||||
int m_baud;
|
||||
int m_UsbLatencyTime;
|
||||
private:
|
||||
void timer_callback();
|
||||
void openSerialPort();
|
||||
void readSerialPort();
|
||||
|
||||
/* UDP info */
|
||||
int m_serverSocket;
|
||||
std::string m_udpAddr;
|
||||
int m_udpPort;
|
||||
struct sockaddr_in m_server;
|
||||
socklen_t m_sockaddrLen;
|
||||
bool m_isBind;
|
||||
char readBuffer[1024];
|
||||
void bindUdp();
|
||||
void readUdp();
|
||||
|
||||
/* read cache */
|
||||
std::string m_input;
|
||||
std::string m_read;
|
||||
private:
|
||||
/* serial port info */
|
||||
serial::Serial imu_ser;
|
||||
std::string m_port;
|
||||
int m_baud;
|
||||
int m_UsbLatencyTime;
|
||||
|
||||
int m_connectionType;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
ProtocolAsensing connect_manager;
|
||||
/* imu log */
|
||||
bool m_isPrintLog = false;
|
||||
FILE* m_logFd = nullptr;
|
||||
/* UDP info */
|
||||
int m_serverSocket;
|
||||
std::string m_udpAddr;
|
||||
int m_udpPort;
|
||||
struct sockaddr_in m_server;
|
||||
socklen_t m_sockaddrLen;
|
||||
bool m_isBind;
|
||||
char readBuffer[1024];
|
||||
|
||||
/* read cache */
|
||||
std::string m_input;
|
||||
std::string m_read;
|
||||
|
||||
int m_connectionType;
|
||||
rclcpp::TimerBase::SharedPtr timer_;
|
||||
ProtocolAsensing connect_manager;
|
||||
/* imu log */
|
||||
bool m_isPrintLog = false;
|
||||
FILE* m_logFd = nullptr;
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -21,7 +21,7 @@ def generate_launch_description():
|
||||
# 连接类型:serial port:0 , UDP:1
|
||||
# default: 0 serial port
|
||||
{"ConnectionType": 0},
|
||||
# 串口设备串 defaule: /dev/ttyUSB0
|
||||
# 串口设备串 defaule: /dev/ttyTHS1
|
||||
{"UART_Port": "/dev/ttyTHS1"},
|
||||
# 串口波特率 default: 115200
|
||||
{"UART_Baudrate": 115200},
|
||||
|
||||
@ -59,7 +59,6 @@ void AGPbox::init_pbox_node()
|
||||
|
||||
this->get_parameter("LogInfo",logInfo);
|
||||
this->get_parameter("LogLevel",logLevel);
|
||||
timer_ = this->create_wall_timer(1ms, std::bind(&AGPbox::timer_callback, this));
|
||||
std::string path = "./ImuDebug.log";
|
||||
|
||||
TinyLog::info("LogPathInfo: %s",logInfo.c_str());
|
||||
@ -84,6 +83,9 @@ void AGPbox::init_pbox_node()
|
||||
{
|
||||
bindUdp();
|
||||
}
|
||||
|
||||
// 创建定时器(在串口/UDP打开之后)
|
||||
timer_ = this->create_wall_timer(1ms, std::bind(&AGPbox::timer_callback, this));
|
||||
}
|
||||
|
||||
void AGPbox::timer_callback()
|
||||
|
||||
@ -1,4 +1,3 @@
|
||||
|
||||
## pbox_node_dirve ROS2 使用方法
|
||||
|
||||
### 编译
|
||||
@ -35,7 +34,7 @@ ros2 topic echo /Imu04
|
||||
| 参数 | 说明 | 默认值 |
|
||||
| ------------------ | ---------------------- | ------------- |
|
||||
| `ConnectionType` | 0=串口, 1=UDP | 1 |
|
||||
| `UART_Port` | 串口设备 | /dev/ttyUSB0 |
|
||||
| `UART_Port` | 串口设备 | /dev/ttyTHS1 |
|
||||
| `UART_Baudrate` | 波特率 | 230400 |
|
||||
| `UDP_Addr` | UDP地址 | 192.168.225.2 |
|
||||
| `UDP_Port` | UDP端口 | 12300 |
|
||||
|
||||
Loading…
Reference in New Issue
Block a user