Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add set_rate service to all sensors #95

Merged
merged 1 commit into from
Feb 10, 2021

Conversation

peci1
Copy link
Contributor

@peci1 peci1 commented Feb 8, 2021

New feature

Helps with issue #81 and osrf/subt#680 (for some users).

Summary

This PR adds an Ignition Transport service ~/set_rate to all sensors. This is to allow users to selectively slow down some sensors if they do not need them running at full rate. This is extremely helpful with rendering sensors when you can anyways process only 6 Hz or similar, but the sensors run on 30.

I also made the service check if the caller doesn't want to set a higher rate than the value of <update_rate> in the sensor's SDF. Such attempts are ignored (with the exception of zero update rate in SDF, which allows to set any rate via this service).

I added a unit test and also tested it running the SubT simulator with EXPLORER_X1_SENSOR_CONFIG_2. This robot has 4 RGBD cameras, and the set_rate service worked for all of them. A single call to set_rate slows down both RGB and D cameras in the RGBD sensor. The real-time ratio of the SubT simulator with the robot was about 20-30% when spawned, and increased to about 90% when I slowed down all 4 cameras to 6 Hz. This might possibly save a lot of money for running Cloudsim :)

I decided to not limit the PR to rendering sensors, where the benefit is obvious, but as <update_rate> is a generic property of all sensors, I also added the service at this level.

Test it

Terminal 1:

ign launch -v4 cloudsim_sim.ign worldName:=simple_cave_01 robotName1:=X1 robotConfig1:=EXPLORER_X1_SENSOR_CONFIG_2 headless:=false

Terminal 2:

ign launch -v4 cloudsim_bridge.ign robotName1:=X1 robotConfig1:=EXPLORER_X1_SENSOR_CONFIG_2 worldName:=simple_cave_01

Terminal 3:

for s in front rear left right; do IGN_TRANSPORT_TOPIC_STATISTICS=1 ign service -s /world/simple_cave_01/model/X1/link/base_link/sensor/${s}_realsense/set_rate --reqtype ignition.msgs.Double --reptype ignition.msgs.Empty --timeout 200 -r 'data: 6.0'; done

Running the bridge makes sure all cameras have a subscriber and generate data. This should slow down the simulation to sub-realtime. When you call the services to slow down the cameras, simulation speed should attack real time. You'll also see this in the simulator console:

[Dbg] [Sensor.cc:266] Setting update rate of sensor X1::base_link::front_realsense to 6 Hz
[Dbg] [Sensor.cc:266] Setting update rate of sensor X1::base_link::rear_realsense to 6 Hz
[Dbg] [Sensor.cc:266] Setting update rate of sensor X1::base_link::left_realsense to 6 Hz
[Dbg] [Sensor.cc:266] Setting update rate of sensor X1::base_link::right_realsense to 6 Hz

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See
    contributing)
  • All tests passed (See
    test coverage)
  • While waiting for a review on your PR, please help review
    another open pull request
    to support the maintainers

Note to maintainers: Remember to use Squash-Merge

@peci1 peci1 requested a review from iche033 as a code owner February 8, 2021 20:59
@github-actions github-actions bot added the 🔮 dome Ignition Dome label Feb 8, 2021
Signed-off-by: Martin Pecka <peckama2@fel.cvut.cz>
Copy link
Contributor

@nkoenig nkoenig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Looks good to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🔮 dome Ignition Dome enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants