Failure to create ros2 publisher: too many input arguments
Show older comments
Hi all
I'm having trouble creating a ros2 publisher (ROS2 Humble, Matlab 2024b), and feel like I'm going crazy. I'm trying to reuse some old code, which I believed was working. Now, however, it fails at the second step: creating the publisher. I've stripped down my script completely, and believe it matches the syntax in the documentation:
p3pNode = ros2node('p3p_node', 2);
p3pPub = ros2publisher(p3pNode,"/p3p","geometry_msgs/Pose");
When I run this, I get the error below:
Error using ros2publisher
Too many input arguments
The node is created successfully, and /geometry_msgs/Pose is a defined message type. What am i doing wrong?
3 Comments
dpb
on 4 Sep 2025
p3pNode = ros2node('p3p_node', 2);
so no can try it out here...
Do you have prior release still installed to try against to see if is possible it did actually work before as you think you recall?
Otherwise, contact Mathworks with request/bug at <Product Support Page>
Depending on your patience level, you could wait a while to see if anybody w/ the required TB does have an answer.
Walter Roberson
on 4 Sep 2025
That looks to be a valid instance of the syntax
pub = ros2publisher(node,topic,type)
so I suspect that you have a third-party ros2publisher() function somewhere on your path. Command
which -all ros2publisher
You should get a single output that looks similar to
/Applications/MATLAB_R2025a.app/toolbox/ros/mlros2/ros2publisher.m
but I suspect that you will get at least two lines.
Alyssa
on 5 Sep 2025
Answers (1)
Abhishek
on 5 Sep 2025
Moved: Jagadeesh Konakalla
on 30 Sep 2025
0 votes
Based on the error message, it seems there may be another function with the same name as ros2publisher located higher in your path. Could you please run the following command and share the output:
which -all ros2publisher
Categories
Find more on Publishers and Subscribers 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!