ros can't receive the message of 'nav_msgs/Path'
Show older comments
the version of MATLAB is R2021A, and I use the ros topic of MATLAB to publish the message to ros node of rviz,both run on Ubuntu.
The problem is that rviz cannot receive the message of "nav_msgs/Path" published by MATLAB, but it can receive the message of "sensor_msgs/JointState" .
Here is the whole program
r = rosrate(30);
joint_name={'joint1_1','joint1_2','joint1_3','joint1_4','joint1_5','joint1_6','joint1_7','joint2_1','joint2_2','joint2_3','joint2_4','joint2_5','joint2_6','joint2_7'};
joint_pub=rospublisher('/joint_states','sensor_msgs/JointState');
path_pub=rospublisher('/manipulator_path','nav_msgs/Path');
joint_msg=rosmessage(joint_pub);
path_msg=rosmessage(path_pub);
pos_msg=rosmessage('geometry_msgs/PoseStamped');
pos_msg.Header.FrameId='base_link';
path_msg.Header.FrameId='base_link';
joint_msg.Name=joint_name;
reset(r);
for i=1:N
pos_msg.Header.Stamp=rostime('now');
pos_msg.Pose.Position.X=(pos(1,4)); %pos(1,4) is a double
pos_msg.Pose.Position.Y=(pos(2,4));
pos_msg.Pose.Position.Z=(pos(3,4));
path_msg.Header.Stamp=rostime('now');
path_msg.Poses(i)=pos_msg;
send(path_pub,path_msg); %This part doesn't work
joint_msg.Header.Stamp=rostime('now');
joint_msg.Position=qq';
send(joint_pub,joint_msg); %This part can work
waitfor(r);
end
I found it can work when I use MATLAB subscriber receive the message of "nav_msgs/Path" published by c++,and publish the received message to rviz, That makes me confused
1 Comment
Jagadeesh Konakalla
on 4 Jul 2022
Hi Yi Liu,
What version of MATLAB that you are using ? What the distribution that your ROS network is using ?
Are you saying that path_msg sent by MATLAB is not received by your ROS network ? Is the issue only with this specific message ? Or any messages from MATLAB are not received by ROS network.
Please provide detailed description of your issues.
Thanks,
Jagadeesh K.
Accepted Answer
More Answers (0)
Categories
Find more on ROS Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!