Pressure sensor implementation [closed]

asked 2013-03-17 03:02:51 -0600

Giacomo gravatar image

updated 2014-01-28 17:15:45 -0600

ngrennan gravatar image

I'm implementing a tape pressure sensor (like this: http: //cnmat.berkeley.edu/system/files/sensor_modules/IMG_7786.jpg) in gazebo as a small link with attached a bumper to keep track of the contacts and measure the total_wrench acting on it (in particular to the z-axis component). This is my urdf:

<robot name="pressure_sensor">

  <link name="base_link">
    <inertial>
      <mass value="0.001"/>
      <origin xyz="0 0 0.0005"/>
      <inertia ixx="1.0" ixy="0.0" ixz="0.0" iyy="1.0" iyz="0.0" izz="1.0"/>
    </inertial>
    <visual>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <box size="0.1 0.5 0.1"/>
      </geometry>
    </visual>
    <collision>
      <origin xyz="0 0 0" rpy="0 0 0"/>
      <geometry>
        <box size="0.1 0.5 0.001"/>
      </geometry>
    </collision>
  </link>

  <gazebo reference="base_link">
    <sensor:contact name="contact_sensor">
    <geom>base_link_geom</geom>
    <updateRate>1.0</updateRate>
    <controller:gazebo_ros_bumper name="gazebo_ros_bumper_controller" plugin="libgazebo_ros_bumper.so">
          <alwaysOn>true</alwaysOn>
          <updateRate>1.0</updateRate>
          <bumperTopicName>weight</bumperTopicName>
          <interface:bumper name="bumper_iface" />
        </controller:gazebo_ros_bumper>
    </sensor:contact>
  </gazebo>

</robot>

and this is the callback function of the bumper topic "weight" subscriber node:

void pressureCallback(const gazebo_msgs::ContactsState::ConstPtr& msg){
    if(msg != NULL && msg->states.size()>0) {
        sum=0;
        for(i=0;i<msg->states.size(); i++){
            if((msg->states[i].geom2_name).compare("[MY_LINK_GEOM]")==0) {
                if(msg->states[i].total_wrench.force.z >= 0) sum+=msg->states[i].total_wrench.force.z;
                else sum-=msg->states[i].total_wrench.force.z;
            }
        }
        ROS_INFO("Weight detected: %f Kg", sum);
    }

where [MY_LINK_GEOM] is the name of the link - of the object I want to measure the weight - that touches my pressure sensor.

It seems to work but I cannot understand why the weight measurements vary in such a different way with the time passing as shown in the figure: https: //www.dropbox.com/s/98lepyi5015ew56/pressure1.png. Is there in your opinion a better implementation for that?

edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2015-12-12 01:14:54.415646