Simulink change PX4 flight mode via MAVROS
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I am trying to change the flight mode of a PX4 drone via MAVROS in Simulink. When I send the command ,MAVROS gives me the error:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/909915/image.png)
However, when I run the equivalent code in MATLAB it works. Is it something encoding related?
My model creates the flight mode string, casts it to a ASCII array which has a length of 128. I then convert from 2-D to 1-D and assign the mode to the bus.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/909920/image.png)
2 comentarios
Ankur Bose
el 4 de Mzo. de 2022
Can you attach the MATLAB code that works for you? We can compare that with Simulink model and see what is the issue
Respuestas (1)
Abhijeet Gadkari
el 4 de Mzo. de 2022
Hello Ewan,
You can use the String Length block to output the length of the String Constant and set that value into the CurrentLength field of the mavros_msgs/SetModeRequest message.
This will allow changing the value of String Constant, state, and the CurrentLength field will update with the new value.
You can use the default limits for CustomMode field.
See the example below:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/914589/image.png)
-Abhijeet
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!