Simulink/ROS: Publishing JointTrajectory Messages for end effector positions

16 vues (au cours des 30 derniers jours)
Ehtisham ul Hasan
Ehtisham ul Hasan le 9 Mar 2021
Commenté : charles guo le 5 Mai 2021
Hi,
I have a human model in Gazebo ROS.The controller is joint trajectory that works fine in ROS environment. Now I have to add a controller but that in Simulink ROS toolbox. Instead of sending Joint Positions I want to send End Effector positions. In other words I am working in Task Space and not in Joint Space. I am unable to access positions from joint trajectory blank message and could not find a solution for quite a while now.
I request if anyone can help me in this regard. I have gone through a question posted in 2017 with title
Simulink/ROS: Publishing JointTrajectory Messages
but it plans in joint space and inputs joint positions. I have to send position commands to my arm group to perform point to point trajectroy planing in Task space(cartesian space). Any help would be appreciated.
Update
As an initial step, I have broken down my problem to first publish one joint position that is to my gripper finger. For this purpose I have used the idea mentioned in the above post highlighted in bold for my gripper joint movement. I do not get any erros in Matlab but I am getting the following error repeatedly in my ROS terminal and hence my joint is not actuated.
Dropping all 1 trajectory point(s), as they occur before the current time. Last point is 0s in the past.
I dont understand why this is happening. Anyhelp would be appreciated please. As if this gets published to the joint and it finally gets actuated, I can eventually take it up further to reach the bigger goal of planning in Cartesian Space.
Thanks
Best
Hasan

Réponses (2)

Remo Pillat
Remo Pillat le 12 Mar 2021
Hi Ehtisham,
Please take a look at the "Control PR2 Arm Movements" example in Robotics System Toolbox. It shows how to create a JointTrajectory message and assign the relevant data (see the rGoalMsg.Trajectory variable in the example). You should be able to extrapolate from that for your own robot, e.g. assign the right joint names.
The example also shows how to use Inverse Kinematics in MATLAB to find the right joint positions for your desired end effector pose.
Once you have it working in MATLAB, you should be able to port this to Simulink pretty easily (there are existing blocks for all the functionality you need).
Hope this help.
  7 commentaires
Ehtisham ul Hasan
Ehtisham ul Hasan le 16 Mar 2021
Hi
I have tried to follow instruction on the link
I could not find ros message defintions folder on my Ubuntu 16.04 or even the javaclasspath.txt. Please guide so that I can update message defintions. Thank you
Ehtisham ul Hasan
Ehtisham ul Hasan le 16 Mar 2021
With regard to your previous comment. Just a refresher, as I think I have not been able to explain correctly. The rosaction in the from of m-file (as per PR2 example) works fine for my model. I get the error what i shared but the execution takes place from m-file as desired for said joint positions.
Hope it gets easier to understand now.
(My concern at the moment is if something works from an m-file regardless of the error, then it should eventually work from simulink through matlab function blocks.)
Best
Hasan

Connectez-vous pour commenter.


Ehtisham ul Hasan
Ehtisham ul Hasan le 18 Mar 2021
Hi,
Following through number of posts and documentation I am currently at the following stage. I found from a mathwork post and at the following link https://it.mathworks.com/help/ros/ref/rosgenmsg.html that though /opt/ros/kinetic/share although holds scattered msg packages but can be given as folderpath in rosgenmsg(foderpath).
I am using ROS Kinetic and Matlab 2020a on Ubuntu 16.04 OS and I did the following in matlab
>> rosgenmsg('/opt/ros/kinetic/share')
Unrecognized function or variable 'rosgenmsg'.
Did you mean:
>> ros2genmsg('/opt/ros/kinetic/share')
Identifying message files in folder '/opt/ros/kinetic/share'..Done.
Error using ros.ros2.internal.createOrGetLocalPython (line 55)
Could not find Python version 3.7 or higher on your system. If you have multiple versions of python, use
pyversion to set the path to the executable for the version of Python to use.
Error in ros2genmsg (line 53)
ros.ros2.internal.createOrGetLocalPython(); %ensure python is available
>> pyenv
ans =
PythonEnvironment with properties:
Version: "2.7"
Executable: "/usr/bin/python"
Library: "libpython2.7.so.1.0"
Home: "/usr"
Status: NotLoaded
ExecutionMode: InProcess
Please note I am using ROS1 and not ROS2 but matlab did not read rosgenmsg command and instead asked for ros2genmsg command and even then did not work.
Please help sort out this issue.
Thanks
Best
Hasan
  12 commentaires
Ehtisham ul Hasan
Ehtisham ul Hasan le 5 Mai 2021
Modifié(e) : Ehtisham ul Hasan le 5 Mai 2021
Hi,
Yes same conclusion, you can only use rosactions from m-file and not from simulink, it does not support that. So, Its better not to waste time on that, I would suggest you see if you can just use rostopics to publish to your robot.
This can be done by understanding this Mathworks thread that helped me. Just go through the thread and directly download the testrosmsgs.zip provided by one of the Mathworks Staff
It rather not easy to understand it as the message definitions in Matlab compared to ROS are too complex the way we need to assign the values. Ammend the code to your joint names and joint positions. But it will only send data to ROS and not to Gazebo and for that you just need ROS time used properly. For which I attach my model for an idea. Also you might need to do a few more coloumn rows switching in the code as I did which you can see by simply comparing the two files. Hope it helps.
NOTE: All this is still in joint space and not in cartesian space unfortunately.
Best Regards
charles guo
charles guo le 5 Mai 2021
Well done! Great appreciation for your help.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Specialized Messages dans Help Center et File Exchange

Produits


Version

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by