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

Carlos depth sensor #72

Merged
merged 5 commits into from
Feb 27, 2025
Merged

Carlos depth sensor #72

merged 5 commits into from
Feb 27, 2025

Conversation

Carlosdc25
Copy link
Contributor

Created depth sensor plugin that took the position of the plugin and published that negative value to the depth topic. Gaussian noise can be added to the measurements from the sensor to mimic real life inaccuracies . The depth sensor plugin is a model plugin, which is relevant because it connects the sensor at the model level. SDF values of the sensor include:

  • offset, which can be used to offset the sensor's measurements to account for things like sensor placement.
  • update_rate, which tells the plugin how many times to try to publish to sensor information.
  • noise_mean, states mean of the Gaussian distribution of noise.
  • noise_stddev, which states the standard deviation of used to create the Gaussian distribution of noise.

I would like to note that the noise_stddev has been set to 0 in sub9.urdf.xacro

Getting Measurement
Using the Entity Component Manager(ECM) we receive a pointer to a Pose component and using the Data() function we can access the location of the entity in 3d space. Then, we update the position gotten by adding the position and rotation of by the offset. A rotation given by the offset does not really matter since we are just measuring depth. The z axis position multiplied by -1 becomes our depth. The depth is in meters btw.

Gaussian Noise
Currently, I have a random seed for the random number generator, that may be something that could want to be changed. Essentially, the way the noise is created is by making a normal distribution from the mean and stddev gotten from the sdf and then getting random number from that distribution and adding that number to the depth. Currently, if the depth exceeds zero the depth gets turned to simply zero.

In the older mil repository mil_msg::DepthStamped was used for messages so for that reasons I added find_package(mil_msgs REQUIRED) to CMakeList.txt and dependency(mil_msgs) to package.xml.

Running this code
To run run the code in one terminal run from the mil2 directory:
colbuild
ros2 launch subjugator_bringup gazebo.launch.py

Then from another terminal run:
source ~/mil2/install/setup.bash
(you might get a message saying not found, but to my understanding it still helps.)
ros2 topic echo /depth

Make sure to click play on the simulator to see the depth messages and you should be good to go.

Photos
This first photo shows the sub floating on the surface with a stddev of 0.1:
Issue#26_MIL_2(0 1 = std)
This photo shows the sub also floating at the surface but with a stddev of 0:
Issue#26_MIL_1

Copy link
Contributor

@Keith-Khadar Keith-Khadar left a comment

Choose a reason for hiding this comment

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

LGTM!

@Keith-Khadar Keith-Khadar merged commit 5ae35de into main Feb 27, 2025
2 checks passed
@Keith-Khadar Keith-Khadar deleted the carlos-depth-sensor branch February 27, 2025 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants