CARLA
Toggle main menu visibility
Loading...
Searching...
No Matches
LibCarla
source
carla
ros2
publishers
RadarPolarToCartesian.h
Go to the documentation of this file.
1
// Copyright (c) 2026 Computer Vision Center (CVC) at the Universitat Autonoma
2
// de Barcelona (UAB).
3
//
4
// This work is licensed under the terms of the MIT license.
5
// For a copy, see <https://opensource.org/licenses/MIT>.
6
7
#pragma once
8
9
#include <array>
10
#include <cmath>
11
12
namespace
carla
{
13
namespace
ros2
{
14
15
// Converts radar polar coordinates (depth in metres, azimuth + altitude in
16
// radians) into a CARLA-handed Cartesian (x, y, z) triple. The convention
17
// matches sensor::data::RadarDetection's polar layout and the per-axis sign
18
// flips applied when packing the wire bytes for ROS 2 subscribers:
19
// x = depth * cos(azimuth) * cos(-altitude)
20
// y = depth * sin(-azimuth) * cos( altitude)
21
// z = depth * sin(altitude)
22
// The y axis carries the same left-handed-to-right-handed mirror used by the
23
// lidar / semantic-lidar publishers; this keeps every CARLA point-cloud
24
// publisher on the same convention.
25
[[nodiscard]]
inline
std::array<float, 3>
RadarPolarToCartesian
(
26
float
depth,
float
azimuth,
float
altitude)
noexcept
{
27
const
float
cos_az = std::cos(azimuth);
28
const
float
sin_az = std::sin(-azimuth);
29
const
float
cos_alt = std::cos(altitude);
30
const
float
sin_alt = std::sin(altitude);
31
const
float
cos_neg_alt = std::cos(-altitude);
32
return
{
33
depth * cos_az * cos_neg_alt,
34
depth * sin_az * cos_alt,
35
depth * sin_alt,
36
};
37
}
38
39
}
// namespace ros2
40
}
// namespace carla
carla::ros2
Definition
AutowareSteeringCompensation.h:15
carla::ros2::RadarPolarToCartesian
std::array< float, 3 > RadarPolarToCartesian(float depth, float azimuth, float altitude) noexcept
Definition
RadarPolarToCartesian.h:25
carla
This file contains definitions of common data structures used in traffic manager.
Definition
SignComponent.h:21
Generated by
1.18.0