Fail to create a ROS publisher/ subcriber for individual project
Show older comments
Hi,
I followed https://www.mathworks.com/help/ros/ug/communicate-with-the-turtlebot.html , and applied this idea to my specific project in my robot, not to the Turtlebot.
Basically, I have my own ROS project, and successfully built it in the Virtual Machine- Ubuntu-Gazebo 9.
After I used roslaunch to start my own project in VM, and in the Matlab I used rosinit(ipaddress) to successfully intialized Matlab global node and connected with ROS master,
and I successfuly got the names of all rostopic by using the command rostopic list in Matlab command window.
---------------------------------------------------------------------------
Now, I am trying to create a new publisher in Matlab to publish information to one topic (name as /mytopic, for example) in my own ROS project by using command: Matlab_Pub = rospublisher("/mytopic").
But I got an error: Failed to create a ROS publisher with topic name /mytopic and message type mytopic_msgs/MotorCmd.
----------------------------------------------------------------------------
And I also got the same issue when trying to creat a new subscriber in Matlab to subscribe to one topic in my own ROS project: Matlab_Sub = rossubscriber("/mytopic")
Could you please give me some insight on this issue and how to fix them?
Thank you so much for your help!
2 Comments
Josh Chen
on 5 Feb 2021
Hello Van,
Can you please share more details about project? From the error message it looks like something was missing.
- What is this "mytopic_msgs/MotorCmd"? Is it a custom message? If yes, have you created a custom message using rosgenmsg?
- Instead of rosinit(ipaddress), if you do "rosinit", and then create such publisher or subscriber, would that work?
- Is this a message already existed in the network? (e.g. published from or subscribed by a node in your virtual machine)
Josh
Van Chuong Nguyen
on 5 Feb 2021
Edited: Van Chuong Nguyen
on 5 Feb 2021
Accepted Answer
More Answers (0)
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!