MATLAB ROS read torque and position

asked 2021-12-25 19:01:09 -0500

mf0099000 gravatar image

I used this package to control the kuka iiwa with torque/trajectory.

Now I have installed this package successfully. I want to achieve the following function.

  1. Using MATLAB to send a command (trajectory control) to ROS, and then make the iiwa robot in gazebo to draw a lucky clover.
  2. When drawing the lucky clover, I want to get the joint states(effort, position) of the iiwa robot.

There is already a rostopic call iiwa/joint_states, with this topic I get the joint state of iiwa robot. The publish rate is 500 HZ.

The message is like this

Name : {1} iiwa_joint_1 {2} iiwa_joint_2 {3} iiwa_joint_3 {4} iiwa_joint_4 {5} iiwa_joint_5 {6} iiwa_joint_6 {7} iiwa_joint_7
Position : [0.03849252747896248, -6.852601709184114e-06, -9.142893652835937e-06, -3.18746457050878e-06, -1.425290537415691e-05, 2.050132787978498e-06, 0.0001859375021959764] Velocity : [-3.4587951142283, -0.04225873471762442, 3.738108556169245, -0.09109035723009323, -0.2732218582540953, -0.04864287523757092, -0.005908027397505496] Effort : [-320, -4.234456976207084, 12.14690976878157, -0.4346553600950879, -0.1395615171617247, -0.01182255304062562, -0.0003513976355266015] Header
Seq : 309593 FrameId :
Sec : 619 Nsec : 588000000

I can also print this rostopic directly in MATLAB

  1. After I get the effort, I will put this effort in a file. Then I will use MATLAB to use Torque control to make the robot in gazebo move, then I will get the joint states of the robot again. I will send the received joint states to the algorithm in MATLAB to optimize the input and output. Then the optimized torque and position will be sent to Gazebo again via MATLAB.

How can I do this?

edit retag flag offensive close merge delete