Subscribe the topic /robot/joint_states ,but i get l_gripper_l_finger_joint message.

17 vues (au cours des 30 derniers jours)
How to reject the {'l_gripper_l_finger_joint'}, i use subscribe Block and the topic /robot/joint_states ,but i get l_gripper_l_finger_joint message.
The physical Baxter sends the gripper states separately on the same topic, so we have to reject it. Can you help me with it.
I use the receive function to read the joint states,the same thing happened again.
The messages returned at different times are as follows,which i don't want these messages.
jntState1 = receive(jointSub1)
jntState1 =
ROS JointState message with properties:
MessageType: 'sensor_msgs/JointState'
Header: [1×1 Header]
Name: {'l_gripper_l_finger_joint'}
Position: 0.020830000000000
Velocity: 0
Effort: 0
These messages are what i want.
jntState1 = receive(jointSub1)
jntState1 =
ROS JointState message with properties:
MessageType: 'sensor_msgs/JointState'
Header: [1×1 Header]
Name: {17×1 cell}
Position: [17×1 double]
Velocity: [17×1 double]
Effort: [17×1 double]
In the simulink the messages returned at different times are as follows:
1、
X@FT[27V{0F6GA0~DAWY6]D.png
2、
$G585LW4)RI08R3BNOBUIMW.png
Can someone help me.
Best wishes!
  2 commentaires
Cam Salzberger
Cam Salzberger le 16 Jan 2019
Just to make sure I'm understanding your situation, can you clarify on these points:
  1. What is the situation in which you are using these messages? I'd like to clarify why you are choosing to use receive, instead of the LatestMessage property, or a NewMessageFcn callback.
  2. What action are you taking after "receiving" the message? Are you calling this in a loop?
  3. To clarify, are you happy with how Simulink is working for you, or did you have a question there too? It wasn't totally clear to me from your question.
Also, I just wanted to let you know that one common design pattern is to use the IsNew output of the Subscribe block to enable an enabled subsytem, so action is only taken when something new is received. You probably just didn't have it since this was just for demonstration purposes, but I wanted to make sure you were aware.
-Cam
snow John
snow John le 17 Jan 2019
Dear Mr Cam !
First of all, I want to thank you for your kindness response !
And I want use these messages to design my feedback controller in simulink and control the
Baxter robot .So i need to know the position and velocity of the joints.Then I use subscribe
block and the topic /robot/joint_states to get the messages from my Baxter robot.
Generally speaking,there are three different formats on the /robot/joint_states channel right
now. Note that 1 and 17 both occur in the same session!
%Length 1:
% Real Baxter
% 'r_gripper_l_finger_joint' or 'l_gripper_l_finger_joint'
% Note: I have never seen a X_gripper_r_finger_joint message on the
% real Baxter. It's not needed for the electric grippers.
% Length 17:
% Real Baxter
% 'head_nod', 'head_pan', 'left_e0', 'left_e1', 'left_s0', 'left_s1',
% 'left_w0', 'left_w1', 'left_w2', 'right_e0', 'right_e1','right_s0',
% 'right_s1', 'right_w0', 'right_w1', 'right_w2', and 'torso_t0'
% Length 19:
% Simulated Baxter
% 'head_pan', 'l_gripper_l_finger_joint', 'l_gripper_r_finger_joint',
% 'left_e0', 'left_e1', 'left_s0', 'left_s1', 'left_w0', 'left_w1',
% 'left_w2', 'r_gripper_l_finger_joint', 'r_gripper_r_finger_joint',
% 'right_e0', 'right_e1', 'right_s0', 'right_s1', 'right_w0',
% 'right_w1', and 'right_w2'
The physical Baxter sends the gripper states separately on the /robot/joint_states topic at
different times .That is why i said need to reject the {'l_gripper_l_finger_joint'}...,and just
get the information of Length 17 .
So do you have a good idea?
I am grateful for any reply.
Best wishes.

Connectez-vous pour commenter.

Réponse acceptée

Cam Salzberger
Cam Salzberger le 17 Jan 2019
Well, I was hoping to get your overall workflow so that I could suggest something that would fit in with it. However, the simpliest solution is simply to check what you have received after you get the message, but before you react with it. For example, if you are using receive in a loop, you can do something like:
while keepMoving
jntStateMsg = receive(jointSub1);
if contains(jntStateMsg.Name, 'head_pan')
% react to he message here
end
pause(0.2)
end
You could even check the message to see if it has each specific joint you are using right before you use it. A similar pattern would apply if you were using a NewMessageFcn callback to the subscriber instead of receive, and using the LatestMessage property in a loop would be similar to receive.
So, overall, my advice would be to check that the message applies to the joints before you use it. Hope that helps!
-Cam
  1 commentaire
snow John
snow John le 18 Jan 2019
I understand, I will try to solve this problem with your suggestion in simulink.
Thank you again for your kindness help.
-John

Connectez-vous pour commenter.

Plus de réponses (0)

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!

Translated by