FERS 0.1.0
The Flexible Extensible Radar Simulator
Loading...
Searching...
No Matches
transmitter.cpp
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-only
2//
3// Copyright (c) 2006-2008 Marc Brooker and Michael Inggs
4// Copyright (c) 2008-present FERS Contributors (see AUTHORS.md).
5//
6// See the GNU GPLv2 LICENSE file in the FERS project root for more information.
7
8/**
9 * @file transmitter.cpp
10 * @brief Contains the implementation of the Transmitter class.
11 */
12
13#include "transmitter.h"
14
15#include "core/parameters.h"
16#include "signal/radar_signal.h"
17
18namespace radar
19{
21 {
22 return (_signal != nullptr) ? _signal->getFmcwChirpSignal() : nullptr;
23 }
24
25 void Transmitter::setPrf(const RealType mprf) noexcept
26 {
28 _prf = 1 / (std::floor(rate / mprf) / rate);
29 }
30
31 void Transmitter::setSchedule(std::vector<SchedulePeriod> schedule)
32 {
33 // The schedule is assumed to be sorted and merged by the parser.
34 _schedule = std::move(schedule);
35 }
36
37 std::optional<RealType> Transmitter::getNextPulseTime(RealType time) const
38 {
39 // If no schedule is defined, assume always on.
40 if (_schedule.empty())
41 {
42 return time;
43 }
44
45 for (const auto& period : _schedule)
46 {
47 // If time is within this period, it's valid.
48 if (time >= period.start && time <= period.end)
49 {
50 return time;
51 }
52 // If time is before this period, skip to the start of this period.
53 if (time < period.start)
54 {
55 return period.start;
56 }
57 // If time is after this period, continue to next period.
58 }
59
60 // Time is after the last scheduled period.
61 return std::nullopt;
62 }
63}
FMCW linear chirp signal implementation.
const class FmcwChirpSignal * getFmcwChirpSignal() const noexcept
Gets the FMCW chirp implementation, if this signal owns one.
std::optional< RealType > getNextPulseTime(RealType time) const
Determines the valid simulation time for a pulse at or after the given time.
void setSchedule(std::vector< SchedulePeriod > schedule)
Sets the active schedule for the transmitter.
const fers_signal::FmcwChirpSignal * getFmcwSignal() const noexcept
Gets the FMCW chirp signal when this transmitter uses one.
void setPrf(RealType mprf) noexcept
Sets the pulse repetition frequency (PRF) of the transmitter.
double RealType
Type for real numbers.
Definition config.h:27
RealType rate() noexcept
Get the rendering sample rate.
Definition parameters.h:121
unsigned oversampleRatio() noexcept
Get the oversampling ratio.
Definition parameters.h:151
Defines the Parameters struct and provides methods for managing simulation parameters.
Classes for handling radar waveforms and signals.
math::Vec3 max
Header file for the Transmitter class in the radar namespace.