- As per my understanding, to set the callbacks for feedback messages a custom message subscriber using the "rossubscriber" function is created. The subscriber is set to listen to the "/fibonacci/feedback" topic, which is where the feedback messages are published for the "/fibonacci" action.
- Then define "customFeedbackCallback" function to handle the recieved feedback messages. This function will be called whenever a new feedback message is received.
Change feedback callback in ROS action client
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
Hi, I'm trying to define a ROS action client with customized callbacks.
The tutorial at the link https://it.mathworks.com/help/ros/ref/simpleactionclient.html works fine but I couldn't change the callbacks of the action client. I'm using the following code to initialize the action lib which, however, does not print anything when feedback messages are received.
action_name = '/fibonacci';
action_type = 'actionlib_tutorials/Fibonacci';
[actClient,goalMsg] = rosactionclient(action_name,action_type,'DataFormat','struct');
actClient.FeedbackFcn = @(~,msg)disp(['Feedback test: ',showDetailsAnyFormat(msg)])
If I comment out the last line, I can see the default print properly. I also tried to set the field actClient.FeedbackFcn equal to a different function handle but did not succeed.
Could you please help me understanding how to set the callbacks?
Thanks in advance!
0 comentarios
Respuestas (1)
Maneet Kaur Bagga
el 21 de Sept. de 2023
Hi Matina,
Please refer to the code below:
action_name = '/fibonacci';
action_type = 'actionlib_tutorials/Fibonacci';
% Create an action client
[actClient, goalMsg] = rosactionclient(action_name, action_type, 'DataFormat', 'struct');
% Create a custom message subscriber for feedback messages
feedbackSub = rossubscriber('/fibonacci/feedback', 'actionlib_tutorials/FibonacciFeedback', @customFeedbackCallback);
% Start the action client
actClient.sendGoal(goalMsg);
% Define the custom feedback callback function
function customFeedbackCallback(~, msg)
% Custom logic for handling feedback messages
disp(['Custom Feedback: ', showDetailsAnyFormat(msg)]);
end
Please refer to the MATLAB Documentation for better understanding of the functions:
rossubscriber
rosactionclient
Hope this helps!
Thank You!
Maneet Bagga
0 comentarios
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!