Camera sensor
CameraSensor is a component that simulates an RGB camera.
Autonomous vehicles can be equipped with many cameras used for various purposes.
In the current version of AWSIM, the camera is used primarily to provide the image to the traffic light recognition module in Autoware.
Prefab
CameraSensorScheduler class
The CameraSensorScheduler class schedules the rendering of CameraSensor. Normally, camera rendering is a highly demanding process. Therefore, the use of multiple camera sensors is performed by the CameraSensorScheduler by staggering the rendering timings one frame at a time.
Setting parameters
| Type | Parameter | Feature |
|---|---|---|
ICameraSensor |
_schedulableCameraSensorComponents |
CameraSensor instances. |
int |
_outputHz |
Period to output. |
CameraSensor class
The CameraSensor class outputs a rendered image with OpenCV parameters applied; it is used by Autoware to recognize traffic lights, for example.
How to use
- Place
CameraSensorScheduler.prefabin the scene. (It will usually be placed under the game object of the vehicle.) - Place
CameraSensor.prefabin the lower level ofCameraSensorScheduler.prefab. Then reference it in theCameraSensorSchedulerinspector. - After the scene is executed,
CameraSensorScheduleris initialized by one of the classes. - The
CameraSensorSchedulercoroutine then continues schedulingCameraSensorrendering and output.
Setting parameters
| Type | Parameter | Feature |
|---|---|---|
int |
_width |
Image width (px). |
int |
_height |
Image height (px). |
float |
_k1 |
Distortion coefficient. For plumb_bob models's k1 parameter. |
float |
_k2 |
Distortion coefficient. For plumb_bob models's k2 parameter. |
float |
_p1 |
Distortion coefficient. For plumb_bob models's p1 parameter. |
float |
_p2 |
Distortion coefficient. For plumb_bob models's p2 parameter. |
float |
_p3 |
Distortion coefficient. For plumb_bob models's k3 parameter. |
Camera |
_camera |
Unity's camera component. |
bool |
_enableLensDistortionCorrection |
Flag whether to apply OpenCV distortion. |
float |
_sharpeningStrength |
Sharpness. |
Output data
It is contained in the CameraSensor.IReadOnlyOutputData type.
| Type | Parameter | Feature |
|---|---|---|
IReadOnlyCameraParameters |
CameraParameters |
|
RenderTexture |
OutputRenderTexture |
Add output callback
CameraSensor can add an Action type callback that takes CameraSensor.IReadOnlyOutputData as an argument.
CameraRos2Publisher class
CameraRos2Publisher converts the output of CameraSensor to ROS2 and publishes the topic. Publish two msgs: camera info and image.
Setting parameters
| Type | Parameter | Feature |
|---|---|---|
string |
_imageTopic |
sensor_msgs/Image msg topic name. |
string |
_cameraInfoTopic |
sensor_msgs/CameraInfo msg topic name. |
string |
_frameId |
Frame ID of ros2. |
QosSettings |
_qosSettings |
Quality of Service settings of ros2. |
CameraSensor |
_cameraSensor |
Target CameraSensor instance. |
Default publish topics
CameraRos2Publisher is configured by default with the following two topics publish.
| Topic | Message type | frame_id |
Hz |
QoS |
|---|---|---|---|---|
/sensing/camera/traffic_light/camera_info |
sensor_msgs/CameraInfo |
traffic_light_left_camera/camera_link |
10 |
|
/sensing/camera/traffic_light/image_raw |
sensor_msgs/Image |
traffic_light_left_camera/camera_link |
10 |
|