# Sensors
## How to use Sensors in URDF and Gazebo
Adding sensors in a URDF for Gazebo is not to difficult if you know the command but it can be very time consuming if you get something wrong. Below is an example of how to setup a generic sensor. You can go [here](https://github.com/ros-simulation/gazebo_ros_pkgs/tree/ros2/gazebo_plugins/include/gazebo_plugins) for more help.
```xml
Gazebo/Red0 0 0 0 0 0true10.0sensor_link
```
## Types of Sensors and configurations
There are many different sensors that can be used in gazebo and in a URDF file and a few of them are listed below. To find more sensor drivers go to the [ros_gazebo github page](https://github.com/ros-simulation/gazebo_ros_pkgs/tree/ros2/gazebo_plugins/include/gazebo_plugins)
### Cameras
To add a camera to a URDF robot and make it work in gazebo you will have to take advantage of the gazebo features in xacro files. below is a sample of how to setup a camera in gazebo.
```xml title="camera.xacro" linenums="1"
Gazebo/Red0 0 0 0 0 0true10.0camera_link-
```
#### Opencv Camera Fix
In opencv, z is pointing into the image (the blue axis), x is right (the red axis), and y is down (green axis), while in the gazebo camera x is pointing into the image and z is up, y is right which is similar to the robot convention of x being forward and z up. To fix this we have to create a new link and rotate it so that everything lines up properly. To do this add the new link and joint as show below and then change the frame name to the new `camera_link_optical`.
```xml linenums="1" hl_lines="1-2 4-11 20"
Gazebo/Red0 0 0 0 0 0true10.0camera_link_optical
```