osrf / mbzirc

Simulator for the MBZIRC Maritime Grand Challenge
Apache License 2.0
72 stars 47 forks source link

Add RF range sensor #151

Closed caguero closed 2 years ago

caguero commented 2 years ago

This pull request adds a new RF range sensor that can be attached to a sensor slot. The sensor periodically publishes an ignition::msgs::Param_V message with the following fields:

How to test it.

  1. Launch an environment:

    ros2 launch mbzirc_ros competition_local.launch.py ign_args:="-v 4 -r simple_demo.sdf"
  2. Launch quadrotor_1:

    ros2 launch mbzirc_ign spawn.launch.py name:=quadrotor_1 world:=simple_demo model:=mbzirc_quadrotor type:=uav x:=-9.5 y:=2 z:=1.05 R:=0 P:=0 Y:=0 slot0:=mbzirc_hd_camera slot1:=mbzirc_rf_range
  3. Launch quadrotor_2:

    ros2 launch mbzirc_ign spawn.launch.py name:=quadrotor_2 world:=simple_demo model:=mbzirc_quadrotor type:=uav x:=9.5 y:=2 z:=1.05 R:=0 P:=0 Y:=0 slot0:=mbzirc_hd_camera slot1:=mbzirc_rf_range
  4. Subscribe to one of the sensor topics, e.g. from quadrotor_1:

    ign topic -e -t /world/simple_demo/model/quadrotor_1/model/sensor_1/rfsensor

You should observe something similar to this output running at 1Hz:

header {
  stamp {
    sec: 11
  }
}
param {
  params {
    key: "model"
    value {
      type: STRING
      string_value: "quadrotor_1"
    }
  }
  params {
    key: "range"
    value {
      type: DOUBLE
      double_value: 12.384630932840144
    }
  }
  params {
    key: "rssi"
    value {
      type: DOUBLE
      double_value: -43.414959792914587
    }
  }
}

Note that there's noise in the measurements. The noise is controlled by the sigma parameter in the plugin. If you change that parameter to 0.0, you should get perfect measurements.

iche033 commented 2 years ago

the RF range sensor works for me as advertised. We're looking to provide multiple configurations, e.g. one short range and one long range. Teams must use the same model on all robots. One idea is to let the sensor set one of the RF params that affects its working range when it's loaded, e.g. tx_power?. I can work on this. @caguero let me know what params to change and what are the reasonable values to set if we want a short and long range model.

iche033 commented 2 years ago

We're looking to provide multiple configurations, e.g. one short range and one long range. Teams must use the same model on all robots. One idea is to let the sensor set one of the RF params that affects its working range when it's loaded, e.g. tx_power?

Did the changes in a separate PR: https://github.com/osrf/mbzirc/pull/155

mjcarroll commented 2 years ago

This pull request adds a new RF range sensor that can be attached to a sensor slot. The sensor periodically publishes an ignition::msgs::Param_V message with the following fields:

Is ignition::msgs::Param_V necessary or is ignition::msgs::Param sufficient? It appears that we are only adding a single "Param" entry in the Param_V message.

iche033 commented 2 years ago

Is ignition::msgs::Param_V necessary or is ignition::msgs::Param sufficient? It appears that we are only adding a single "Param" entry in the Param_V message.

I think there is one "Param" entry per nearby robot with RF range sensor so if there are 3 robots in the world, the msg should have 2 Param entries? e.g.

header {
  stamp {
    sec: 70
  }
}
param {
  params {
    key: "model"
    value {
      type: STRING
      string_value: "quadrotor_2"
    }
  }
  params {
    key: "range"
    value {
      type: DOUBLE
      double_value: 23.0579936363202
    }
  }
  params {
    key: "rssi"
    value {
      type: DOUBLE
      double_value: -50.433359389710894
    }
  }
}
param {
  params {
    key: "model"
    value {
      type: STRING
      string_value: "quadrotor_3"
    }
  }
  params {
    key: "range"
    value {
      type: DOUBLE
      double_value: 12.740026362761711
    }
  }
  params {
    key: "rssi"
    value {
      type: DOUBLE
      double_value: -43.734428493676688
    }
  }
}
mjcarroll commented 2 years ago

Yes, my understanding was just going off the PR description. Once I started looking at the implementation, I realized my mistake. So in coordination with https://github.com/gazebosim/ros_gz/pull/261, I believe that the ROS message parameter entries will be:

param_0/model: quadrotor_1
param_0/range: 12.0
param_0/rssi: -45.0

And so on for each entry.

caguero commented 2 years ago

the RF range sensor works for me as advertised. We're looking to provide multiple configurations, e.g. one short range and one long range. Teams must use the same model on all robots. One idea is to let the sensor set one of the RF params that affects its working range when it's loaded, e.g. tx_power?. I can work on this. @caguero let me know what params to change and what are the reasonable values to set if we want a short and long range model.

Thanks! Parameters adjusted in your PR directly.

caguero commented 2 years ago

API documentation updated in https://github.com/osrf/mbzirc/wiki/Robot-and-sensor-APIs#uav-and-usv-payload-sensors.