调整了控制指令发送的位置
This commit is contained in:
@@ -261,7 +261,25 @@ bool AUV150::ListenLoop()
|
|||||||
m_counter = p->counter;
|
m_counter = p->counter;
|
||||||
updateStatus(*p);
|
updateStatus(*p);
|
||||||
postStatusUpdate("NAV");
|
postStatusUpdate("NAV");
|
||||||
|
// 计算控制量
|
||||||
|
|
||||||
|
// 发送消息
|
||||||
|
try
|
||||||
|
{
|
||||||
|
m_TcpSocket->iSendMessage(&m_CommandFrame, sizeof(CommandFrame_150AUV));
|
||||||
|
m_controlGap = MOOSTime() - m_desiredVarTime;
|
||||||
|
m_controlTime = MOOSTime();
|
||||||
|
m_bConnected = true;
|
||||||
|
}
|
||||||
|
catch(XPCException &e)
|
||||||
|
{
|
||||||
|
m_bConnected = false;
|
||||||
|
std::cerr << "there was trouble sending message: "
|
||||||
|
<< e.sGetException() << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 计算控制频率
|
||||||
m_samplingTime = MOOSTime();
|
m_samplingTime = MOOSTime();
|
||||||
message_count++;
|
message_count++;
|
||||||
double elapsed_time = m_samplingTime - start_time;
|
double elapsed_time = m_samplingTime - start_time;
|
||||||
@@ -280,7 +298,6 @@ bool AUV150::ListenLoop()
|
|||||||
m_faultCodes.insert(0x12); //无数据接收
|
m_faultCodes.insert(0x12); //无数据接收
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (XPCException & e)
|
catch (XPCException & e)
|
||||||
{
|
{
|
||||||
@@ -294,37 +311,8 @@ bool AUV150::ListenLoop()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool AUV150::WriteLoop()
|
bool AUV150::WriteLoop()
|
||||||
{
|
{
|
||||||
double start_time = MOOSTime();
|
|
||||||
int message_count = 0;
|
|
||||||
double last_send_time = MOOSTime();
|
|
||||||
double gap;
|
|
||||||
|
|
||||||
//5Hz发送
|
|
||||||
while(!WritingThread_.IsQuitRequested()){
|
while(!WritingThread_.IsQuitRequested()){
|
||||||
if((MOOSTime() - last_send_time) >= (m_controlCycle))
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
m_TcpSocket->iSendMessage(&m_CommandFrame, sizeof(CommandFrame_150AUV));
|
|
||||||
m_controlGap = MOOSTime() - m_desiredVarTime;
|
|
||||||
m_bConnected = true;
|
|
||||||
}
|
|
||||||
catch(XPCException &e)
|
|
||||||
{
|
|
||||||
m_bConnected = false;
|
|
||||||
std::cerr << "there was trouble sending message: "
|
|
||||||
<< e.sGetException() << "\n";
|
|
||||||
}
|
|
||||||
message_count++;
|
|
||||||
double elapsed_time = MOOSTime() - start_time;
|
|
||||||
if(elapsed_time > 1.0) { // 每秒更新一次频率
|
|
||||||
m_real_write_freq = message_count / elapsed_time;
|
|
||||||
message_count = 0;
|
|
||||||
start_time = MOOSTime();
|
|
||||||
}
|
|
||||||
last_send_time = MOOSTime();
|
|
||||||
}
|
|
||||||
if(!m_bConnected)
|
if(!m_bConnected)
|
||||||
{
|
{
|
||||||
m_real_read_freq = 0;
|
m_real_read_freq = 0;
|
||||||
@@ -437,6 +425,17 @@ bool AUV150::buildReport()
|
|||||||
doubleToString(m_controlGap, 5) + "s"
|
doubleToString(m_controlGap, 5) + "s"
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
// printTable(
|
||||||
|
// {"Connect", "Read", "Writ" ,"Conter" ,"Gap","Gap2"},
|
||||||
|
// {
|
||||||
|
// (isConnected() ? "Yes" : "No"),
|
||||||
|
// doubleToString(getRealReadFreq(), 4) + " Hz",
|
||||||
|
// doubleToString(getRealWriteFreq(), 4) + " Hz",
|
||||||
|
// ulintToString(getCounter()),
|
||||||
|
// doubleToString(m_controlGap, 5) + "s",
|
||||||
|
// doubleToString((m_controlTime-m_samplingTime),5)
|
||||||
|
// }
|
||||||
|
// );
|
||||||
m_msgs << "Fault Codes: ";
|
m_msgs << "Fault Codes: ";
|
||||||
for (uint8_t code : getFaultCodes()) {
|
for (uint8_t code : getFaultCodes()) {
|
||||||
m_msgs << uintToString(code) + " ";
|
m_msgs << uintToString(code) + " ";
|
||||||
@@ -539,8 +538,8 @@ bool AUV150::updateStatus(FeedbackFrame_150AUV &feedbackFrame)
|
|||||||
m_status.velocityEast = feedbackFrame.velocityEast / 100.0f;
|
m_status.velocityEast = feedbackFrame.velocityEast / 100.0f;
|
||||||
m_status.velocityNorth = feedbackFrame.velocityNorth / 100.0f;
|
m_status.velocityNorth = feedbackFrame.velocityNorth / 100.0f;
|
||||||
m_status.velocityDown = feedbackFrame.velocityDown / 100.0f;
|
m_status.velocityDown = feedbackFrame.velocityDown / 100.0f;
|
||||||
m_status.insLongitude = feedbackFrame.insLongitude / 100000.0f - 180.0f;
|
m_status.insLongitude = feedbackFrame.insLongitude / 1e7 - 180.0f;
|
||||||
m_status.insLatitude = feedbackFrame.insLatitude / 100000.0f - 90.0f;
|
m_status.insLatitude = feedbackFrame.insLatitude / 1e7 - 90.0f;
|
||||||
m_status.insAltitude = feedbackFrame.insAltitude / 100.0f;
|
m_status.insAltitude = feedbackFrame.insAltitude / 100.0f;
|
||||||
m_status.dvlVelX = feedbackFrame.dvlVelX / 100.0f;
|
m_status.dvlVelX = feedbackFrame.dvlVelX / 100.0f;
|
||||||
m_status.dvlVelY = feedbackFrame.dvlVelY / 100.0f;
|
m_status.dvlVelY = feedbackFrame.dvlVelY / 100.0f;
|
||||||
|
|||||||
Reference in New Issue
Block a user