something
This commit is contained in:
@@ -5,64 +5,16 @@
|
||||
#ifndef _OPTIONS_H_
|
||||
#define _OPTIONS_H_
|
||||
|
||||
#ifdef FIX_OPTIONS
|
||||
#ifdef SHOW_ARMOR_BOX
|
||||
#define show_armor_box true
|
||||
#else
|
||||
#define show_armor_box false
|
||||
#endif
|
||||
|
||||
#ifdef SHOW_ARMOR_BOXES
|
||||
#define show_armor_boxes true
|
||||
#else
|
||||
#define show_armor_boxes false
|
||||
#endif
|
||||
|
||||
#ifdef SHOW_LIGHT_BLOBS
|
||||
#define show_light_blobs true
|
||||
#else
|
||||
#define show_light_blobs false
|
||||
#endif
|
||||
|
||||
#ifdef SHOW_ORIGIN
|
||||
#define show_origin true
|
||||
#else
|
||||
#define show_origin false
|
||||
#endif
|
||||
|
||||
#ifdef SAVE_LABELLED
|
||||
#define save_labelled true
|
||||
#else
|
||||
#define save_labelled false
|
||||
#endif
|
||||
|
||||
#ifdef RUN_WITH_CAMERA
|
||||
#define run_with_camera true
|
||||
#else
|
||||
#define run_with_camera false
|
||||
#endif
|
||||
|
||||
#ifdef SAVE_VIDEO
|
||||
#define save_video true
|
||||
#else
|
||||
#define save_video false
|
||||
#endif
|
||||
|
||||
#ifdef COLLECT_DATA
|
||||
#define collect_data true
|
||||
#else
|
||||
#define collect_data false
|
||||
#endif
|
||||
#else /* FIX_OPTIONS */
|
||||
extern bool show_armor_box;
|
||||
extern bool show_armor_boxes;
|
||||
extern bool show_light_blobs;
|
||||
extern bool show_origin;
|
||||
extern bool save_labelled;
|
||||
extern bool run_with_camera;
|
||||
extern bool save_video;
|
||||
extern bool collect_data;
|
||||
#endif /* FIX_OPTIONS */
|
||||
extern bool show_armor_box;
|
||||
extern bool show_armor_boxes;
|
||||
extern bool show_light_blobs;
|
||||
extern bool show_origin;
|
||||
extern bool save_labelled;
|
||||
extern bool run_with_camera;
|
||||
extern bool save_video;
|
||||
extern bool collect_data;
|
||||
extern bool wait_uart;
|
||||
|
||||
void process_options(int argc, char *argv[]);
|
||||
|
||||
|
||||
@@ -40,14 +40,13 @@ bool CameraWrapper::init() {
|
||||
for(i=0; i<camera_cnts; i++){
|
||||
camera_status = CameraInit(&camera_enum_list[i], -1, -1, &h_camera);
|
||||
if (camera_status != CAMERA_STATUS_SUCCESS) {
|
||||
LOGE("Camera 0 initialization failed with code %d. See camera_status.h to find the code meaning.", camera_status);
|
||||
goto stop;
|
||||
CameraUnInit(h_camera);
|
||||
continue;
|
||||
}
|
||||
CameraGetFriendlyName(h_camera, camera_name);
|
||||
if(name=="NULL" || strcmp(name.data(), camera_name)==0){
|
||||
break;
|
||||
}
|
||||
stop:
|
||||
CameraUnInit(h_camera);
|
||||
}
|
||||
if(i >= camera_cnts){
|
||||
@@ -72,7 +71,7 @@ stop:
|
||||
CameraGetExposureTime(h_camera, &t);
|
||||
LOGM("Exposure time: %lfms", t/1000.0);
|
||||
// 模拟增益4
|
||||
CameraSetAnalogGain(h_camera, 60);
|
||||
CameraSetAnalogGain(h_camera, 63);
|
||||
// 使用预设LUT表
|
||||
CameraSetLutMode(h_camera, LUTMODE_PRESET);
|
||||
// 抗频闪
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
#include <log.h>
|
||||
#include <cstring>
|
||||
|
||||
#ifndef FIX_OPTIONS
|
||||
bool show_armor_box = false;
|
||||
bool show_armor_boxes = false;
|
||||
bool show_light_blobs = false;
|
||||
@@ -15,6 +14,7 @@ bool save_labelled = false;
|
||||
bool run_with_camera = false;
|
||||
bool save_video = false;
|
||||
bool collect_data = false;
|
||||
bool wait_uart = false;
|
||||
|
||||
void process_options(int argc, char *argv[]){
|
||||
if(argc >= 2){
|
||||
@@ -61,12 +61,12 @@ void process_options(int argc, char *argv[]){
|
||||
}else if(strcmp(argv[i], "--collect-data") == 0){
|
||||
collect_data = true;
|
||||
LOGM("Enable data collection!");
|
||||
}else if(strcmp(argv[i], "--wait-uart") == 0){
|
||||
wait_uart = true;
|
||||
LOGM("Wait uart until available!");
|
||||
}else{
|
||||
LOGW("Unknown option: %s. Use --help to see options.", argv[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void process_options(int argc, char *argv[]){};
|
||||
#endif /* FIX_OPTIONS */
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
#include <uart/uart.h>
|
||||
#include <energy/param_struct_define.h>
|
||||
#include <options/options.h>
|
||||
#include <log.h>
|
||||
|
||||
using std::cout;
|
||||
@@ -17,11 +18,14 @@ GMAngle_t aim;
|
||||
|
||||
|
||||
Uart::Uart(){
|
||||
fd = open("/dev/ttyUSB0", O_RDWR);
|
||||
if(fd < 0)
|
||||
{
|
||||
cerr<<"open port error"<<endl;
|
||||
return;
|
||||
if(wait_uart){
|
||||
while((fd = open("/dev/ttyUSB0", O_RDWR)) < 0);
|
||||
}else{
|
||||
fd = open("/dev/ttyUSB0", O_RDWR);
|
||||
if(fd < 0) {
|
||||
cerr<<"open port error"<<endl;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if(set_opt(fd, 115200, 8, 'N', 1) < 0 )
|
||||
@@ -146,8 +150,12 @@ void Uart::sendTarget(float x, float y, float z) {
|
||||
buff[6] = static_cast<char>((z_tmp >> 0) & 0xFF);
|
||||
buff[7] = 'e';
|
||||
|
||||
write(fd, buff, 8);
|
||||
|
||||
int cnt=0;
|
||||
while((cnt+=write(fd, buff+cnt, 8-cnt))!=-1 && cnt<8);
|
||||
if(cnt==-1 && wait_uart){
|
||||
LOGE("Uart send fail, the uart device may offline! Restart!");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t Uart::receive() {
|
||||
|
||||
Reference in New Issue
Block a user