Compare commits
2 Commits
593cb37cf7
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 1e21138668 | |||
| 8728fd88e5 |
@@ -30,8 +30,14 @@ void output_control_data(const cv::Point2f* ballistic_point,
|
||||
std::ostringstream send_str;
|
||||
|
||||
// Calculate offset (based on actual image center)
|
||||
int ballistic_offset_x = static_cast<int>(ballistic_point->x - img_center.x);
|
||||
int ballistic_offset_y = static_cast<int>(img_center.y - ballistic_point->y);
|
||||
int ballistic_offset_x = -static_cast<int>(ballistic_point->x - img_center.x);
|
||||
if ( abs(ballistic_offset_x) > 320){
|
||||
ballistic_offset_x = ( ballistic_offset_x / abs( ballistic_offset_x ) ) * 320 ;
|
||||
}
|
||||
int ballistic_offset_y = -static_cast<int>(img_center.y - ballistic_point->y);
|
||||
if ( abs(ballistic_offset_y) > 180 ) {
|
||||
ballistic_offset_y = ( ballistic_offset_x / abs( ballistic_offset_x ) ) * 180 ;
|
||||
}
|
||||
|
||||
// Color simplification mapping
|
||||
std::string simplified_color = target_color;
|
||||
@@ -39,7 +45,7 @@ void output_control_data(const cv::Point2f* ballistic_point,
|
||||
else if (target_color == "blue") simplified_color = "b";
|
||||
|
||||
// Construct send string
|
||||
send_str << "s " << simplified_color << " " << std::to_string(ballistic_offset_x) << " " << std::to_string(ballistic_offset_y) << "\n";
|
||||
send_str << "#s " << simplified_color << " " << std::to_string(ballistic_offset_x) << " " << std::to_string(ballistic_offset_y) << "*\n";
|
||||
|
||||
// Send data
|
||||
if (ttl_communicator != nullptr) {
|
||||
@@ -72,15 +78,7 @@ int main(int /*argc*/, char* /*argv*/[]) {
|
||||
|
||||
if (Numbe == 0) {
|
||||
// 执行 shell 命令(注意安全风险!)
|
||||
int result = std::system("soude chmod 777 /dev/tty*");
|
||||
|
||||
// 可选:检查命令是否成功执行
|
||||
if (result == -1) {
|
||||
std::cerr << "Failed to execute system command.\n";
|
||||
} else {
|
||||
std::cout << "Permissions updated (if any tty devices exist).\n";
|
||||
}
|
||||
|
||||
std::system("sudo chmod 777 /dev/tty*");
|
||||
Numbe++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user