receiving from a subscriber in ROS is taking indefinite time resulting in a fail
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello,
I am new to working with ROS. I am trying to implement my own Franka Emika robot arm Pick and Place using this provided example https://www.mathworks.com/help/robotics/ug/pick-and-place-workflow-in-gazebo-using-ros.html.
Bulk of my code so far is word for word from this example.
My issue is that when carrying out this function
jMsg = receive(rossubscriber('/franka_gripper/joint_states'));
Script keeps going on forever until I stop it manually. When stop it i get this error
In ros.Subscriber/receive (line 456)
util.waitUntilTrue(@() obj.MessageCount > nMessages, ...
From my understanding, this means that
- There is no data being published for the subscriber to recieve, which I belive is not true due to the fact that i tested what response /franka_gripper/joint_states is outputting using rostopic echo, and it is clear that i am getting a constant flow of data at a high frequency.
Header
Stamp
Sec : 6413
Nsec : 927000000
Seq : 181740
FrameId :
Name : {1} panda_finger_joint1 {2} panda_finger_joint2
Position : [0.01344062581074294, 0.0134407826620155]
Velocity : [-1.977668961469445e-05, 1.969509947091252e-05]
Effort : [2.712875049178911e-06, -2.796997938358815e-06]
2. Some other subscriber is interfering with this topic, of which i tested using rostopic info /franka_gripper/joint_states
Type: sensor_msgs/JointState
Publishers:
* /gazebo (http://vm:34813/)
Subscribers:
* /joint_state_publisher (http://vm:45961/)
- I tried restarting my VM, restarting Gazbo, changing buffer size, disabling all publishers and subscribers except the one I am testing which resulted in nothing but failure
- It is worth mentioning that the connection is set since i can move the robot, set config of the robot and other.
- This issue sometimes also applies to the topic /franka_state_controller/joint_states
Immediate help would be highly appreciated :)
0 commentaires
Réponses (2)
Jagadeesh Konakalla
le 8 Mai 2023
Hi Omar,
Which verion of MATLAB that you are using ?
Are you able to run the example provided by Mathworks without any issue ?
Above, you mentioned that ros topic echo is working. Did you run this command in MATLAB or VM ?
Are you using the VM provided by Mathowkrs ? If so, let me know from where you downloaded.
Thanks,
Jagadeesh K.
2 commentaires
Prabeen Sahu
le 10 Mai 2023
Hi Omar,
These are the VMs shipped by MathWorks:
The Pick and Place Workflow example that you mentioned, works fine with the Melodic and Dashing VM. Please run the example with MathWorks shipped VM and check if it is working.
In your code you are creating subscriber inside receive function as mentioned below.
jMsg = receive(rossubscriber('/franka_gripper/joint_states'));
This is not an efficient way of using subscriber. In your code you can create the subscriber before receive() (May be as a member of the class like obj.ROSinfo.controllerStateSub) and use the handle of subscriber in receive(subHandle).
If still you are not able to get the message you could try:
- Using subHandle.LatestMessage as mentioned in this link, and check if you are able to get the message.
- Use a callback to check if subscriber is getting the messages. Using a callback function is another approach you can consider(follow the same link mentioned above). By defining a callback function and setting it for the subscriber, the callback will be executed each time a new message arrives. This approach allows for more flexibility in handling messages asynchronously.
-Prabeen
0 commentaires
Voir également
Catégories
En savoir plus sur Publishers and Subscribers dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!