ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

ros action in python connection with matlab

asked 2020-04-20 03:27:30 -0500

m.kowsar gravatar image

hi all I wanna to create ros action(server and client) in python and then send goal to it from matlab. Is it possible or not?If it's possible please help me what shoud I do exactly? thanks in advance

edit retag flag offensive close merge delete


To answer this you'd have to figure out whether Matlab can create an action server.

If that is possible, then you can do what you are asking.

If not, then not.

gvdhoorn gravatar image gvdhoorn  ( 2020-04-20 07:54:33 -0500 )edit

thanks a lot @gvdhoom.As I understand I should write an action in c++ or python and a client in matlab.

m.kowsar gravatar image m.kowsar  ( 2020-04-21 00:32:39 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2020-06-26 10:37:14 -0500

j.fagan gravatar image

It absolutely is possible, and there are 3 main things you need need to do.

Create Python Action Server

This is pretty straight forward with lots of resources and demonstrations on how to set up an action client. I found this page on actionlib to be the most helpful. It demonstrates setting up your Catkin package structure, creating .action files as well as a Python simple action server.

Create Matlab Action Client

Even simpler is creating a Matlab action client to send goals to the Python action server. There are various overloaded signatures of the function as can be seen in the rosactionclient documentation. My preference is to use the function signature

[client,goalMsg] = rosactionclient(actionname)

This sets us up with a client to send goals to the action server as well as a blank goal message that we can modify and send. There is an example of its use on the aforementioned documentation page.

Facilitate Custom Messages in Matlab

Action servers may require the use of custom ROS messages (stored in .action files). Matlab has access to a lot of built in messages as can be seen with the command rosmsg list. If you do not see the your action server's messages in the returned list then you need to follow these instructions for ROS Custom Message Support. I was not able to run these instructions on a Mac, but I was able to successfully run them on a Linux machine. Once I had the directory of generated messages on my Linux machine I was able to copy them to my Mac and they worked perfectly.

edit flag offensive delete link more

Question Tools



Asked: 2020-04-20 03:27:30 -0500

Seen: 302 times

Last updated: Apr 20 '20