connect simulink ROS2 pub/subs with PX4

6 visualizzazioni (ultimi 30 giorni)
Panos
Panos il 12 Dic 2023
Modificato: Panos il 3 Gen 2024
Hello,
I am having issues trying to establish communication between Simulink and PX4 running in SITL mode.
The set up is as:
- PX4 is running on a terminal and is connected to my Simulink Flight Dynamics Model. Data are exchanged as expected and the vehicle is able to take off etc..
- Qgroundcontrol is also in the loop and coms are established and working fine
- I am running the Fast-DDS agent in a docker container and this is working fine, I can see data are communicated from the client on the PX4 side to the Agent in the docker.
- working on macOS machine
Having all the above running in good order, when on the Matlab/Simulink side i try to list the available topics I get just the below listed and all PX4 messages are not visible.
>> ros2 topic list
/parameter_events
/rosout
It seems like there is some component missing, or the configuration on the Matlab/Simulink side is not the right one?
Is it nessessary to run a ros2 network in a different terminal, or Matlab/Simulink sort this out internally?
Any thoughts?
Thanks,
  2 Commenti
Karthik Reddy Vennapureddy
Hi Panos,
What is the ROS Domain ID in which you are running the FastDDS agent in docker container. Also what is the ROS 2 Distribution in which fast dds agent is running (Is it Humble or Galactic, etc)?
If the topics are being published on a different ROS domain id, you wont be able to see the list of topics as part of "ros2 topic list".
"ros2 topic list" honors environment variable "ROS_DOMAIN_ID". By default ROS_DOMAIN_ID will be 0 when MATLAB/Simulink is running. so ros2 topic list introspects the topics present on domain id 0. For example, If you want to see topics that are available on Domain ID 25, you can execute the following command:
ros2 topic list DomainID 25
Also, It is not necessary to run a ros2 network in a different terminal, MATLAB/Simulink will do this internally. Let me know, if you are still unable to view the topics.
Thanks,
Karthik Reddy
Panos
Panos il 20 Dic 2023
Hi Karthik, thanks for your message.
I set the ROS_DOMAIN_ID variable in the docker container running the FastDDS agent to 0 (export ROS_DOMAIN_ID=0)
Run again the PX4, FastDD agent and Matlab 'ros2 topic list' command without success.
I don't have any ros2 distribution installed inside that container. Is it required? why?
Thanks

Accedi per commentare.

Risposte (1)

Anurag
Anurag il 21 Dic 2023
Hi Panos,
I understand that you are having issues in establishing communication between Simulink and PX4.
Follow the steps below for solving the issue:
  • Make sure you have sourced the ROS 2 setup files in the terminal where you are running MATLAB/Simulink. You can do this by running the following command:
source /path/to/ros2/install/setup.bash
  • PX4 topics may be under a specific namespace. Try listing topics with different namespaces:
ros2 topic list -n /px4
  • While MATLAB/Simulink may internally manage the ROS 2 network, in some cases, it might be necessary to run a separate ROS 2 network. You can try running the ROS 2 network manually in a separate terminal:
ros2 run ros2 run ros2cli network list
  • Ensure that there are no firewall issues preventing communication between MATLAB/Simulink and the Fast-DDS agent running in the Docker container.
Please refer to the documentation below for the same:
Hope it helps,
Regards,
Anurag
  1 Commento
Panos
Panos il 2 Gen 2024
Modificato: Panos il 3 Gen 2024
Hi Anurag,
Thanks for your answer. I tried to follow your instructions, but I am getting the following issues:
>> ros2 topic list -n /fmu
Error using ros2
Expected input number 3 to match one of these values:
'node', 'topic', 'service', 'action', 'msg', 'bag', 'DomainID'
The input, '-n', did not match any of the valid values.
and,
>> ros2 run ros2cli network list
Error using ros2
Expected input number 1 to match one of these values:
'node', 'topic', 'service', 'action', 'msg', 'bag'
The input, 'run', did not match any of the valid values.
Using Matlab's terminal the commad
ros2 topic list
lists the available PX4 topics.
However, when I instantiate a subscriber and attempt to receive messages from any topic, that fails.
>>node = ros2node("/control_node");
odomSub = ros2subscriber(node,"/fmu/out/vehicle_odometry","px4_msgs/VehicleOdometry");
timeLimit = 10;
receive(odomSub,timeLimit);
with the error:
Error using ros2subscriber/receive
Subscriber did not receive any messages and timed out.
Same result when I try the same example on Simulink.
I have checked the value of the ROS_DOMAIN_ID variable. It is set to 0 on Matlab. Also, in the terminal I am running the DDS agent I have exported its value to 0 as well (export ROS_DOMAIN_ID=0)
Thanks

Accedi per commentare.

Prodotti


Release

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by