adam_zhuo 3 anni fa
parent
commit
e31e9511b9
4 ha cambiato i file con 72 aggiunte e 55 eliminazioni
  1. 0 55
      .gitignore
  2. 30 0
      lib/imu_data.h
  3. 34 0
      lib/serial_port.h
  4. 8 0
      out/README.md

+ 0 - 55
.gitignore

@@ -1,62 +1,7 @@
-# ---> Python
-# Byte-compiled / optimized / DLL files
-__pycache__/
-*.py[cod]
-*$py.class
-
 .vscode/
-
 # C extensions
 *.so
 
-# Distribution / packaging
-.Python
-env/
-build/
-develop-eggs/
-dist/
-downloads/
-eggs/
-.eggs/
-lib/
-lib64/
-parts/
-sdist/
-var/
-*.egg-info/
-.installed.cfg
-*.egg
-
-# PyInstaller
-#  Usually these files are written by a python script from a template
-#  before PyInstaller builds the exe, so as to inject date/other infos into it.
-*.manifest
-*.spec
-
-# Installer logs
-pip-log.txt
-pip-delete-this-directory.txt
-
-# Unit test / coverage reports
-htmlcov/
-.tox/
-.coverage
-.coverage.*
-.cache
-nosetests.xml
-coverage.xml
-*,cover
-
-# Translations
-*.mo
-*.pot
-
-# Django stuff:
-*.log
 
-# Sphinx documentation
-docs/_build/
 
-# PyBuilder
-target/
 

+ 30 - 0
lib/imu_data.h

@@ -0,0 +1,30 @@
+#ifndef _IMU_DATA_H
+#define _IMU_DATA_H
+
+#pragma once
+
+#include <iostream>
+#include <iomanip>
+#include <Windows.h>
+#include <stdio.h>
+#include <conio.h>
+#include <sstream>
+#include "serial_port.h"
+
+using namespace std;
+
+int initSerialPort(string imu_dev);
+
+int getImuData(void);
+void closeSerialPort(void);
+
+float getAcc(int flag);
+float getAngular(int flag);
+float getAngle(int flag);
+float getQuat(int flag);
+
+int makeYawZero(void);
+int updateIICAddr(string input);
+void show_imu_data(void);
+
+#endif

+ 34 - 0
lib/serial_port.h

@@ -0,0 +1,34 @@
+
+#ifndef _SERIALPORT_H
+#define _SERIALPORT_H
+
+class SerialPort
+{
+public:
+	SerialPort();
+	~SerialPort();
+
+	// 打开串口,成功返回true,失败返回false
+	// portname(串口名): 在Windows下是"COM1""COM2"等,在Linux下是"/dev/ttyS1"等
+	// baudrate(波特率): 9600、19200、38400、43000、56000、57600、115200 
+	// parity(校验位): 0为无校验,1为奇校验,2为偶校验,3为标记校验(仅适用于windows)
+	// databit(数据位): 4-8(windows),5-8(linux),通常为8位
+	// stopbit(停止位): 1为1位停止位,2为2位停止位,3为1.5位停止位
+	// synchronizeflag(同步、异步,仅适用与windows): 0为异步,1为同步
+	bool open(const char* portname, int baudrate, char parity, char databit, char stopbit, char synchronizeflag=1);
+
+	//关闭串口,参数待定
+	void close();
+
+	//发送数据或写数据,成功返回发送数据长度,失败返回0
+	int send(const void *buf,int len);
+
+	//接受数据或读数据,成功返回读取实际数据的长度,失败返回0
+	int receive(void *buf,int maxlen);
+
+private:
+	int pHandle[16];
+	char synchronizeflag;
+};
+
+#endif

+ 8 - 0
out/README.md

@@ -0,0 +1,8 @@
+<!--
+ * @Copyright(C): 2016-2021 ROS小课堂 www.corvin.cn
+ * @Author: adam_zhuo
+ * @Date: 2021-11-25 14:18:39
+ * @Description: file content
+ * @History: 20210429:-adam_zhuo
+-->
+### BLANK