Hello, I'm develeoping a simple observer-based controller and I'm trying to implement it on PX4 stack. I'm developing a SITL scheme with Simulink-Based plant model as shown in Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model - MATLAB & Simulink - MathWorks. I developed a simple simulink model to check connetivity between my controller and the plant but there is a problem. I'm able to follow all the steps in the tutorial mentioned above but at the end I get the following error in the Simulink controller model:
action: EXT_INIT Creating Target Handler (XCP on TCP/IP)... Build directory: C:\Users\paolo\OneDrive\Documenti\Tesi_magistrale\SITL\partialInformation_controller_SITL_Simulink_ert_rtw Target name: 127.0.0.1 Target port: 17725 action: EXT_CONNECT Connecting to the target...
External Mode Open Protocol Connect command failed
Caused by:
  • Could not connect to target application: XCP TCP/IP error: Connect failed
Component:Simulink | Category:Block diagram error
Unable to connect to the 'PX4 Host Target' target for 'partialInformation_controller_SITL_Simulink'.
I think the problem is on model side beacuse if I run the quadcopter model in the example Monitor and Tune PX4 Host Target Flight Controller with Simulink-Based Plant Model - MATLAB & Simulink - MathWorks my controller seems to connect succesfully with this model. This is my model for test connectivity, I'm trying to publish a simple message HIL_GPS with a dummy altitude:
And this is the controller I have developed:
Someone can help me?
Thanks in advice,
Paolo

댓글 수: 1

Did the host target window launch for you?
Also check if some other application is blocking 17725 port.

댓글을 달려면 로그인하십시오.

 채택된 답변

Manoj Velmurugan
Manoj Velmurugan 2022년 11월 25일

0 개 추천

PX4 Host target waits until it receives the HIL_SENSOR message. PX4 Host target has not started running as there is no HIL_SENSOR message in your plant model.
For more information, see the following lines in Firmware\src\modules\simulator\simulator.cpp
#if defined(ENABLE_LOCKSTEP_SCHEDULER)
// We want to prevent the rest of the startup script from running until time
// is initialized by the HIL_SENSOR messages from the simulator.
while (true) {
if (Simulator::getInstance() && Simulator::getInstance()->has_initialized()) {
break;
}
system_usleep(100);
}
#endif

댓글 수: 1

Paolo
Paolo 2022년 11월 25일
Hi Manoj, thank for the answer. I added the HIL_SENSOR block and all seems to work weel. Thanks!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터 및 File Exchange에서 UAV에 대해 자세히 알아보기

제품

릴리스

R2022b

질문:

2022년 11월 22일

댓글:

2022년 11월 25일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by