Robotics StackExchange | Archived questions

Using ROS to read joint angles of gazebo model in MATLAB

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';
rosinit(ipaddress)
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">
   <static>false</static>
      <link name='link1'>
        <pose>0 0 2.4 0 0 0</pose>
        <collision name='collision1'>
          <geometry>
        <cylinder>
          <radius>.1</radius>
          <length>.8</length>
        </cylinder>
          </geometry>
        </collision>

        <visual name='visual1'>
          <geometry>
            <cylinder>
              <radius>0.1</radius>
              <length>0.8</length>
            </cylinder>
          </geometry>
        </visual>

    <inertial>
      <pose>0 0 0.4 0 0 0</pose>
      <inertia>
    <ixx>0.058640</ixx>
    <ixy>0.000124</ixy>
    <ixz>0.000615</ixz>
    <iyy>1.058786</iyy>
    <iyz>0.000014</iyz>
    <izz>1.532440</izz>
      </inertia>
      <mass>2.000</mass>
    </inertial>
  </link>
<joint type="revolute" name="joint1">
  <pose>0 0 -0.4 0 0 0</pose>
  <child>link1</child>
  <parent>world</parent>
  <axis>
    <xyz>0 1 0</xyz>
  </axis>
</joint>
  </model>
</sdf>

With Thanks

Masoud

Asked by Masoud on 2016-05-17 23:47:36 UTC

Comments

Answers