Using ROS to read joint angles of gazebo model in MATLAB

asked 2016-05-17 23:47:36 -0500

Masoud gravatar image

updated 2016-10-24 09:08:28 -0500

ngrennan gravatar image

Hello people

I'm trying to control an inverted pendulum using MATLAB. I have successfully created the model and applied constant joint torques using following codes in MATLAB:

ipaddress = '192.168.x.x';
gazebo = ExampleHelperGazeboCommunicator();
PendulumModel = ExampleHelperGazeboModel('1link','gazeboDB');
Pendulum = spawnModel(gazebo,PendulumModel,[0 0 0]);
[links, joints] = getComponents(Pendulum);
stopTime = 50; % Seconds
effort = 2 * 10 * 0.8; % Newton-meters
jointTorque(Pendulum, joints{1}, stopTime, effort);

My main problem is that I can't feedback the pendulum joint angle in MATLAB. Would you please help me to get joint angles in MATLAB.

Additional Info: MATLAB version : R2016a Running Kubuntu through vmware player which has ros hydro installed and configured to connect to MATLAB

SDF Model file:

<?xml version='1.0'?>
<sdf version='1.4'>
  <model name="Pendulum">
      <link name='link1'>
        <pose>0 0 2.4 0 0 0</pose>
        <collision name='collision1'>

        <visual name='visual1'>

      <pose>0 0 0.4 0 0 0</pose>
<joint type="revolute" name="joint1">
  <pose>0 0 -0.4 0 0 0</pose>
    <xyz>0 1 0</xyz>

With Thanks


edit retag flag offensive close merge delete