ROS Toolbox: Header.FrameId for publisher /move_base_simple/goal not recognised

Good afternoon,
I am trying to move a mobile robot (MIR) declared in ROS from simulink. In order to do that i added to my project a publisher node from ROS Toolbox with node '/move_base_simple/goal', then with the Blank Message of type '/geometry_msgs/PoseStamped' i created a bus giving the coordinates that i need and "map" for the frameId. when i run the program the robot does not move, and if i type 'rostopic echo /move_base_simple/goal' on matlab i can notice that the the frameId field is empty, while the coordinates are correct, someone knows why the program can't read the frame Id? (i tried to move the MIR in ROS with the same command and it works)

9 Comments

Hi Dario,
To resolve the issue, ensure that the frameId is correctly set in the message before publishing it. You can explicitly set the frameId in the code where you populate the message. Here is an example of how you can set the frameId in MATLAB:
% Create a message object
msg = rosmessage('geometry_msgs/PoseStamped');
% Set the frameId
msg.Header.FrameId = 'map';
% Set the coordinates
msg.Pose.Position.X = 1.0; msg.Pose.Position.Y = 2.0; msg.Pose.Position.Z = 0.0;
% Publish the message
send(pub, msg);
By explicitly setting the frameId in the message object before publishing, you ensure that the robot receives the correct frame information along with the coordinates. Hope that answers your question.
Unfortunately it does not work, because the program does not take the map in ROS. If the MIR is in a starting position x and i move it manually away from it, once i run the matlab program he will go in that position. i tried changing the frameId with random names and it does the same, so i guess that the problem is that he is not able to see the 'map' present in ROS (that is not on windows but on a virtual machine on ubuntu), so he can't reach the coordinates that i give him. (i already did the connection between matlab and ROS)
Hi Dario, sorry to hear that. One possible explanation for this behavior could be that the MATLAB program is not properly subscribing to the map topic in ROS, which is crucial for the robot to receive and navigate based on the map data. Since you mentioned changing the frameId with random names without success, it indicates that the problem might lie in the connection between MATLAB and ROS rather than just a naming issue. To address this issue, you may need to ensure that your MATLAB program is effectively subscribing to the correct ROS topics, including the map topic that provides essential mapping data for navigation. Double-checking the connection setup between MATLAB and ROS, ensuring proper message passing, and verifying that the map data is being correctly transmitted to the MIR robot are crucial steps in troubleshooting this problem. Additionally, considering that ROS is running on a virtual machine on Ubuntu while MATLAB is on Windows, make sure that there are no network or firewall issues hindering the communication between these two systems. Ensuring a seamless connection between the virtual machine hosting ROS and your Windows environment is essential for successful data exchange and navigation commands. Utilize ROS debugging tools such as rostopic, rviz, or tf_echo to monitor data flow, visualize frames, and diagnose any potential communication errors.
Good morning, i am doing some researches about this problem, i noticed this:
In the first picture i am sending the command '/move_base' from ROS, and i visualize it to simulink; in this case the command runs succesfully and the robot moves, in fact i can see the command also in simulink (simulink read the frameId and the coordinates corresponding at the ROS command)
In the second image i do the opposite, so i send the command '/move_base' from simulink to ROS with the block 'publish', and i visualize the result in the ROS terminal with the command 'rostopic echo /move_base/goal'; as is shown in the following picture the frameID is not recognised (in the mean time i am reading the topic /map to see what i get, and i get the map):
i also checked the rqt_graph in ROS to see how the nodes are comunicating:
The mir_bridge and the Simulink node (/prova1_sim_27850) are comunicating as is shown, so i don't get why i can't send the frameID correctly to it.
sorry for the long message, i wanted to be as precise as i can.
Hi Dario,
Have you tried rostopic echo, to inspect the messages being published on the '/move_base' topic. Because this will help you to verify that the frameID field is present and contains the expected value. This can also help identify any discrepancies in the message content. In addition to 'rostopic echo', also consider visualizing the message contents using tools like RViz to inspect the frameID information graphically. This can provide a clearer understanding of how the frameID is being handled within the ROS environment.
Hi,
yes i tried to use the rostopic echo command, in the second picture, sliding on the right, there is the result of that:
about Rviz, i used it, if i publish the command /move_base_simple/goal in simulink i can see the action correctly on RVIZ, but the robot just does not move.
Hi Dario,
Can you share the code when sending message from simulink to ROS and what block were you using because you mentioned that opposite of it works (ROS to simulink).
Good morning,
This is che command i send from Simulink to ROS:
if i check the result with 'rostopic echo /move_base_simple/goal', both in matlab and ROS, i see the coordinates but the frameID field is empty, and the robot does not move. (i also tried without giving Header.stamp.sec and Header.stamp.nsec but the result is the same).
And yes, if i launch the command /move_base_simple/goal from ROS, with the same inputs, it works.
This is the example of the command on ROS:
Hi Dario,
In your comments, I see the screenshot you are sharing, verify that the topic you are publishing to in Simulink matches the topic subscribed to by the ROS node responsible for moving the robot. Consistency in topic names and message formats is essential for proper communication. By aligning the message structure in Simulink with the expected format in ROS and ensuring that all necessary fields, including the frameID, are correctly populated, you should be able to resolve the issue of the robot not moving when sending commands from Simulink. Remember, attention to detail in message formatting is key to seamless communication between different systems.

Sign in to comment.

Answers (1)

Hi,
I do not have your entire model. My suggestion for you to use the Header Assignment block as described in the following page.
Thanks,
Jagadeesh K

Asked:

on 27 Jun 2024

Community Treasure Hunt

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

Start Hunting!