0
$\begingroup$

Rosanswers logo

Hello,everyone! I am a novice in gazebo. I want to simulate my robot arm in gazebo. Here is part of my urdf file.


<?xml version="1.0" ?>
<robot name="jixiebi">
    <link name="arm1">
        <visual>
            <geometry>
                <mesh filename="arm - arm1-1.STL"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0.00039 -0.00037 0.0"/>
            <material name="arm1_color">
                <color rgba="0.752941 0.752941 0.752941 1"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <mesh filename="arm - arm1-1.STL"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0.00039 -0.00037 0.0"/>
        </collision>
        <inertial>
            <mass value="1.04075"/>
            <inertia ixx="0.004368" ixy="-0.00001" ixz="0.000002" iyy="0.004367" iyz="-0.000001" izz="0.002456"/>
            <origin rpy="0 0 0" xyz="0.000393 -0.000373 -0.074418"/>
        </inertial>
    </link>
    <joint name="arm1-arm2" type="continuous">
        <limit effort="1000.0" lower="-3.1415926" upper="3.1415926" velocity="0.5"/>
        <dynamics damping="0.0" friction="0.0"/>
        <parent link="arm1"/>
        <child link="arm2"/>
        <origin rpy="0 0 0" xyz="0 0 0.173"/>
        <axis xyz="0 0 1"/>
    </joint>
    <link name="arm2">
        <visual>
            <geometry>
                <mesh filename="arm - arm2-1.STL"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="arm2_color">
                <color rgba="0.752941 0.752941 0.752941 1"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <mesh filename="arm - arm2-1.STL"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0 0 0.0"/>
        </collision>
        <inertial>
            <mass value="1.26789"/>
            <inertia ixx="0.003947" ixy="-0.000001" ixz="-0.000617" iyy="0.006723" iyz="-0.000004" izz="0.005568"/>
            <origin rpy="0 0 0" xyz="-0.100667 0.000085 -0.013708"/>
        </inertial>
    </link>
    <joint name="arm2-arm3" type="continuous">
        <limit effort="1000.0" lower="-3.1415926" upper="3.1415926" velocity="0.5"/>
        <dynamics damping="0.0" friction="0.0"/>
        <parent link="arm2"/>
        <child link="arm3"/>
        <origin rpy="0 0 0" xyz="0.084 0 0.107"/>
        <axis xyz="1 0 0"/>
    </joint>
    <link name="arm3">
        <visual>
            <geometry>
                <mesh filename="arm - arm3-1.STL"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0 0 0"/>
            <material name="arm3_color">
                <color rgba="0.752941 0.752941 0.752941 1"/>
            </material>
        </visual>
        <collision>
            <geometry>
                <mesh filename="arm - arm3-1.STL"/>
            </geometry>
            <origin rpy="0 0 0" xyz="0 0 0"/>
        </collision>
        <inertial>
            <mass value="0.65756"/>
            <inertia ixx="0.002035" ixy="-0.000006" ixz="-0.000239" iyy="0.002506" iyz="-0" izz="0.001401"/>
            <origin rpy="0 0 0" xyz="0.156093 0.000249 0.270754"/>
        </inertial>
    </link>
    <gazebo reference="arm1">
        <material>Gazebo/White</material>
        <turnGravityOff>false</turnGravityOff>
        <selfCollide>true</selfCollide>
    </gazebo>
    <gazebo reference="arm1-arm2">
        <stopKd value="1.0"/>
        <stopKp value="1000000.0"/>
        <fudgeFactor value="0.5"/>
    </gazebo>
    <gazebo reference="arm2">
        <material>Gazebo/White</material>
        <turnGravityOff>true</turnGravityOff>
        <selfCollide>true</selfCollide>
    </gazebo> 
    <gazebo reference="arm2-arm3">
        <stopKd value="1.0"/>
        <stopKp value="1000000.0"/>
        <fudgeFactor value="0.5"/>
    </gazebo>
    <gazebo reference="arm3">
        <material>Gazebo/White</material>
        <turnGravityOff>true</turnGravityOff>
        <selfCollide>true</selfCollide>
    </gazebo>  
</robot>

I have a c++ program that can calculate the value of the angle to rotate when you specify a goal position. So my question is how to make joints rotated a specified angle. I have reviewed the gazebo here and I found there just offer a gazebo/apply_joint_effort.


When the model was loaded successfully,I executed the following command.


rosservice call gazebo/apply_joint_effort '{joint_name: arm1-arm2, effort: 0.01, start_time: 10000000000, duration: 1000000000}'

the arm2 rotate relative to the arm1 , but the arm3 also rotate relative to the arm2 and they kept running when I executed the following command.


rosservice call gazebo/clear_joint_forces '{joint_name: arm1-arm2}'

I went to know how to make the arm3 static relative to the arm2 when I just apply force to the joint arm1-arm2 and how to stop them.


Originally posted by shenhaobin on ROS Answers with karma: 19 on 2011-09-04

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

The URDF simply describes the kinematic and dynamic properties of your robot mechanism. If you want to make a joint rotate a specific angle, you need to write a controller that commands the joint to do something. The controller will probably monitor the joint position, and command joint efforts or velocities. See the robot mechanism controllers wiki page for examples of controllers that run in the pr2 controller infrastructure.


Originally posted by Wim with karma: 2915 on 2011-09-11

This answer was ACCEPTED on the original site

Post score: 3

$\endgroup$
0
$\begingroup$

Rosanswers logo

To expand on @Wim's answer, one example of using the pr2 controller infrastructure is here: pr2_arm_gazebo. It can easily be used on a non-PR2 arm, too. Here are the most important things you'll have to do (from pr2_arm_gazebo):

URDF file:

<gazebo>
  <controller:gazebo_ros_controller_manager name="gazebo_ros_controller_manager" plugin="libgazebo_ros_controller_manager.so">
    <alwaysOn>true</alwaysOn>
    <updateRate>1000.0</updateRate>
  </controller:gazebo_ros_controller_manager>
</gazebo>

Also, your URDF file needs transmissions for each joint, otherwise the pr2_controller_manager won't work.

Launch file:

...

<!-- Default Controllers -->
<rosparam command="load" file="$(find pr2_controller_configuration_gazebo)/pr2_arm_controllers.yaml" />

<!-- Controller Manager -->
<include file="$(find pr2_controller_manager)/controller_manager.launch" />

<!-- Controllers that come up loaded -->
<node name="default_loaded_controllers_spawner"
      pkg="pr2_controller_manager" type="spawner" output="screen"
      args="--wait-for=/calibrated r_arm_controller" />

<!-- Fake calibration -->
<node pkg="rostopic" type="rostopic" name="fake_joint_calibration"
      args="pub /calibrated std_msgs/Bool true" />

...

pr2_arm_controllers.yaml:

 r_arm_controller:
   type: "robot_mechanism_controllers/JointTrajectoryActionController"
   joints:
     - r_shoulder_pan_joint
     - r_shoulder_lift_joint
     - r_upper_arm_roll_joint
     - r_elbow_flex_joint
     - r_forearm_roll_joint
     - r_wrist_flex_joint
     - r_wrist_roll_joint
   gains:
     r_shoulder_pan_joint: {p: 2400.0, d: 18.0, i: 800.0, i_clamp: 4.0}
     r_shoulder_lift_joint: {p: 1200.0, d: 10.0, i: 700.0, i_clamp: 4.0}
     r_upper_arm_roll_joint: {p: 1000.0, d: 6.0, i: 600.0, i_clamp: 4.0}
     r_elbow_flex_joint: {p: 700.0, d: 4.0, i: 450, i_clamp: 4.0}
     r_forearm_roll_joint: {p: 300.0, d: 6.0, i: 300, i_clamp: 2.0}
     r_wrist_flex_joint: {p: 300.0, d: 4.0, i: 300, i_clamp: 2.0}
     r_wrist_roll_joint: {p: 300.0, d: 4.0, i: 300, i_clamp: 2.0}
   joint_trajectory_action_node:
     joints:
       - r_shoulder_pan_joint
       - r_shoulder_lift_joint
       - r_upper_arm_roll_joint
       - r_elbow_flex_joint
       - r_forearm_roll_joint
       - r_wrist_flex_joint
       - r_wrist_roll_joint
     constraints:
       goal_time: 0.6
       r_shoulder_pan_joint:
         goal: 0.02
       r_shoulder_lift_joint:
         goal: 0.02
       r_upper_arm_roll_joint:
         goal: 0.02
       r_elbow_flex_joint:
         goal: 0.02
       r_forearm_roll_joint:
         goal: 0.02
       r_wrist_flex_joint:
         goal: 0.02
       r_wrist_roll_joint:
         goal: 0.02

Now you'll have to send trajectories to the arm and experiment to find the right PID parameters. (Hint: they'll probably be rather in the range of 0-10 if you use a transmission mechanical reduction of 1).


Originally posted by Martin Günther with karma: 11816 on 2011-09-11

This answer was NOT ACCEPTED on the original site

Post score: 4

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.