• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Scala-Robotics-Simulator / PPS-22-srs / #419

28 Aug 2025 10:57AM UTC coverage: 46.919% (+0.9%) from 46.066%
#419

push

github

srs-mate
feat(robot): validate sensors during validation

14 of 15 new or added lines in 5 files covered. (93.33%)

70 existing lines in 6 files now uncovered.

1241 of 2645 relevant lines covered (46.92%)

6.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

54.78
/src/main/scala/io/github/srs/utils/SimulationDefaults.scala
1
package io.github.srs.utils
2

3
import java.awt.Color
4
import java.util.UUID
5

6
import scala.concurrent.duration.{ DurationInt, FiniteDuration }
7

8
import cats.effect.unsafe.implicits.global
9
import io.github.srs.model.entity.*
10
import io.github.srs.model.entity.dynamicentity.Robot
11
import io.github.srs.model.entity.dynamicentity.actuator.{ Actuator, Wheel as ActWheel }
12
import io.github.srs.model.entity.dynamicentity.behavior.Policy
13
import io.github.srs.model.entity.dynamicentity.sensor.*
14
import io.github.srs.model.environment.Environment
15
import cats.effect.IO
16
import io.github.srs.model.illumination.LightMap
17
import io.github.srs.model.illumination.engine.SquidLibFovEngine
18
import io.github.srs.model.illumination.model.ScaleFactor
19

20
object SimulationDefaults:
21

×
22
  object Illumination:
23

3✔
24
    val GridThreshold = 10_000
25
    val LightThreshold = 2
8✔
26

5✔
27
    object Occlusion:
28
      val FullRotation: Double = 90.0
3✔
29
      val AlmostZero: Double = 1e-6
8✔
30

5✔
31
  object UI:
32

×
33
    object SimulationViewConstants:
34
      val IdDisplayLength = 8
×
35
      val PositionDecimals = 2
×
36
      val OrientationDecimals = 1
×
37
      val DefaultRobotInfo = "Select a robot to view details"
×
38
      val StopConfirmMessage = "Are you sure you want to stop the simulation?\n\nClick Yes to stop, No to continue."
×
39
      val StopConfirmTitle = "Stop Simulation"
×
40

×
41
    object Colors:
42
      @inline private def rgb(r: Int, g: Int, b: Int) = new java.awt.Color(r, g, b)
×
43
      @inline private def rgba(r: Int, g: Int, b: Int, a: Int) = new java.awt.Color(r, g, b, a)
×
44
      def backgroundLight: Color = rgb(250, 250, 250)
×
45
      def backgroundMedium: Color = rgb(245, 245, 245)
×
46
      def border: Color = rgb(200, 200, 200)
×
47
      def text: Color = rgb(60, 60, 60)
×
48
      def obstacleGradientStart: Color = rgb(120, 120, 120)
×
49
      def obstacleGradientEnd: Color = rgb(80, 80, 80)
×
50
      def obstacleBorder: Color = rgb(60, 60, 60)
×
51
      def robotDefault: Color = rgb(100, 150, 255)
×
52
      def robotDefaultDark: Color = rgb(50, 100, 200)
×
53
      def robotDefaultBorder: Color = rgb(0, 50, 150)
×
54
      def robotSelected: Color = rgb(255, 100, 100)
×
55
      def robotSelectedDark: Color = rgb(200, 50, 50)
×
56
      def robotSelectedBorder: Color = rgb(150, 0, 0)
×
57
      def robotShadow: Color = rgba(0, 0, 0, 50)
×
58
      def lightCenter: Color = rgba(255, 255, 200, 200)
×
59
      def lightEdge: Color = rgba(255, 140, 0, 80)
×
60
      def buttonHover: Color = rgb(230, 230, 230)
×
61
      def buttonPressed: Color = rgb(220, 235, 250)
×
62
      def timeDisplay: Color = rgb(50, 50, 50)
×
63

×
64
    end Colors
65

66
    object Fonts:
67
      val fontSize = 12
×
68
      val titleSize = 12
×
69

×
70
    object Spacing:
71
      val standardPadding = 10
×
72
      val innerPadding = 5
×
73
      val componentGap = 10
×
74

×
75
    object Dimensions:
76
      val buttonWidth = 150
×
77
      val buttonHeight = 30
×
78
      val robotListWidth = 250
×
79
      val robotListHeight = 300
×
80
      val infoAreaRows = 6
×
81
      val infoAreaColumns = 25
×
82

×
83
    object Strokes:
84
      val obstacleStroke = 1.5f
×
85
      val robotShadowStroke = 3f
×
86

×
87
    object Icons:
88
      val play = "\u25B6"
×
89
      val stop = "\u23F9"
×
90
      val pause = "\u23F8"
×
91
  end UI
×
92

93
  val duration: Option[Long] = None
94
  val seed: Option[Long] = None
8✔
95
  val debugMode = true
4✔
96
  val binarySearchDurationThreshold: FiniteDuration = 1.microseconds
2✔
97

13✔
98
  /**
99
   * Alternative light map configurations for different use cases
100
   */
101
  object LightMapConfigs:
102

3✔
103
    /**
104
     * Default light map with caching enabled Uses scale factor 10 for a good balance of performance and precision
105
     */
106
    lazy val baseLightMap: LightMap[IO] =
107
      LightMap
11✔
108
        .create[IO](ScaleFactor.default, SquidLibFovEngine)
30✔
109
        .unsafeRunSync()
19✔
110

68✔
111
    /**
112
     * High-precision light map for detailed rendering Uses scale factor 100 for maximum precision.
113
     *
114
     * @return
115
     *   A [[LightMap]] configured for high precision, or the default light map if the scale factor is invalid.
116
     */
117
    def HPLightMap: LightMap[IO] =
118
      ScaleFactor
×
119
        .validate(80)
×
120
        .map { scale =>
×
121
          LightMap
×
122
            .create[IO](scale, SquidLibFovEngine)
123
            .unsafeRunSync()
124
        }
125
        .getOrElse(baseLightMap)
×
126

×
127
    /**
128
     * Fast light map for real-time simulation Uses scale factor 5 for maximum performance.
129
     *
130
     * @return
131
     *   A [[LightMap]] configured for fast computation, or the default light map if the scale factor is invalid.
132
     */
133
    def fastLightMap: LightMap[IO] =
134
      ScaleFactor
×
135
        .validate(10)
×
136
        .map { scale =>
×
137
          LightMap
×
138
            .create[IO](scale, SquidLibFovEngine)
139
            .unsafeRunSync()
140
        }
141
        .getOrElse(baseLightMap)
×
142

×
143
    /**
144
     * Custom light map with specific scale factor Curried for better composition.
145
     *
146
     * @param scaleFactor
147
     *   The desired scale factor (cells per meter).
148
     * @return
149
     *   A [[LightMap]] configured with the specified scale factor, or the default light map if the scale factor is
150
     *   invalid.
151
     */
152
    def withScale(scaleFactor: Int): LightMap[IO] =
153
      ScaleFactor
×
154
        .validate(scaleFactor)
×
155
        .map { scale =>
×
156
          LightMap
×
157
            .create[IO](scale, SquidLibFovEngine)
158
            .unsafeRunSync()
159
        }
160
        .getOrElse(baseLightMap)
×
161

×
162
  end LightMapConfigs
163

164
  object SimulationConfig:
165
    val maxCount = 10_000
×
166

×
167
  object Environment:
168
    val defaultWidth: Int = 10
3✔
169
    val minWidth: Int = 1
8✔
170
    val maxWidth: Int = 500
4✔
171

4✔
172
    val defaultHeight: Int = 10
173
    val minHeight: Int = 1
4✔
174
    val maxHeight: Int = 500
4✔
175

4✔
176
    val defaultEntities: Set[Entity] = Set.empty
177
    val maxEntities: Int = 200
10✔
178

5✔
179
  object StaticEntity:
180

×
181
    object Obstacle:
182
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000000")
3✔
183
      val defaultPosition: Point2D = (0.0, 0.0)
13✔
184
      val defaultOrientation: Orientation = Orientation(0.0)
8✔
185
      val defaultWidth: Double = 1.0
10✔
186
      val defaultHeight: Double = 1.0
4✔
187

5✔
188
    object Light:
189
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000001")
3✔
190
      val defaultPosition: Point2D = (0.0, 0.0)
13✔
191
      val defaultOrientation: Orientation = Orientation(0.0)
8✔
192
      val defaultRadius: Double = 0.05
10✔
193
      val defaultIlluminationRadius: Double = 1.0
4✔
194
      val defaultIntensity: Double = 1.0
4✔
195
      val defaultAttenuation: Double = 1.0
4✔
196

5✔
197
    object Boundary:
198
      val defaultPosition: Point2D = (0.0, 0.0)
3✔
199
      val defaultOrientation: Orientation = Orientation(0.0)
12✔
200
      val defaultWidth: Double = 1.0
10✔
201
      val defaultHeight: Double = 1.0
4✔
202

5✔
203
  end StaticEntity
204

205
  object DynamicEntity:
206
    val zeroSpeed: Double = 0.0
3✔
207
    val minSpeed: Double = -1.0
8✔
208
    val maxSpeed: Double = 1.0
4✔
209
    val halfSpeed: Double = 0.5
4✔
210

5✔
211
    object Actuator:
212

×
213
      object DifferentialWheelMotor:
214
        val defaultWheel: ActWheel = ActWheel()
3✔
215

22✔
216
        object Wheel:
217
          val defaultSpeed: Double = 1.0
3✔
218
          val defaultShape: ShapeType.Circle = ShapeType.Circle(0.1)
8✔
219
          val MinSpeed: Double = 0.0
6✔
220
          val MaxSpeed: Double = 5.0
4✔
221

5✔
222
    object Sensor:
223

×
224
      object ProximitySensor:
225
        val DefaultOffset: Double = 0.0
3✔
226
        val DefaultRange: Double = 5.0
8✔
227

5✔
228
    object Robot:
229
      import SimulationDefaults.DynamicEntity.Robot.defaultShape.radius
3✔
230

231
      val defaultMaxRetries = 10
232

6✔
233
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000002")
234
      val defaultPosition: Point2D = (0.0, 0.0)
9✔
235
      val defaultShape: ShapeType.Circle = ShapeType.Circle(0.5)
8✔
236
      val defaultOrientation: Orientation = Orientation(0.0)
6✔
237
      val defaultActuators: Seq[Actuator[Robot]] = Seq.empty
10✔
238
      val defaultSensors: Vector[Sensor[Robot, Environment]] = Vector.empty
11✔
239
      val MinRadius: Double = 0.01
10✔
240
      val MaxRadius: Double = 0.5
4✔
241

4✔
242
      val selectionStroke: Float = 3f
243
      val normalStroke: Float = 1f
2✔
244
      val arrowLengthFactor: Double = 0.6
2✔
245
      val arrowWidthFactor: Double = 0.3
2✔
246
      val minArrowWidth: Float = 2f
2✔
247

2✔
248
      val stdProximitySensors: Vector[Sensor[Robot, Environment]] = Vector(
249
        ProximitySensor(Orientation(0.0), radius),
6✔
250
        ProximitySensor(Orientation(45.0), radius),
23✔
251
        ProximitySensor(Orientation(90.0), radius),
15✔
252
        ProximitySensor(Orientation(135.0), radius),
15✔
253
        ProximitySensor(Orientation(180.0), radius),
15✔
254
        ProximitySensor(Orientation(225.0), radius),
15✔
255
        ProximitySensor(Orientation(270.0), radius),
15✔
256
        ProximitySensor(Orientation(315.0), radius),
15✔
257
      )
15✔
258

3✔
259
      val stdLightSensors: Vector[Sensor[Robot, Environment]] = Vector(
260
        LightSensor(Orientation(0.0)),
6✔
261
        LightSensor(Orientation(45.0)),
20✔
262
        LightSensor(Orientation(90.0)),
12✔
263
        LightSensor(Orientation(135.0)),
12✔
264
        LightSensor(Orientation(180.0)),
12✔
265
        LightSensor(Orientation(225.0)),
12✔
266
        LightSensor(Orientation(270.0)),
12✔
267
        LightSensor(Orientation(315.0)),
12✔
268
      )
12✔
269
      val defaultPolicy: Policy = Policy.AlwaysForward
3✔
270
    end Robot
5✔
271
  end DynamicEntity
272

273
  object Fields:
UNCOV
274

×
275
    object Simulation:
276
      val self: String = "simulation"
3✔
277
      val duration: String = "duration"
8✔
278
      val seed: String = "seed"
4✔
279

5✔
280
    object Environment:
281
      val self: String = "environment"
3✔
282
      val width: String = "width"
8✔
283
      val height: String = "height"
4✔
284
      val entities: String = "entities"
4✔
285

5✔
286
    object Entity:
287
      val id: String = "id"
3✔
288
      val position: String = "position"
8✔
289
      val x: String = "x"
4✔
290
      val y: String = "y"
2✔
291
      val orientation: String = "orientation"
2✔
292

5✔
293
      object StaticEntity:
UNCOV
294

×
295
        object Obstacle:
296
          val self: String = "obstacle"
3✔
297
          val width: String = "width"
8✔
298
          val height: String = "height"
4✔
299

5✔
300
        object Light:
301
          val self: String = "light"
3✔
302
          val radius: String = "radius"
8✔
303
          val illuminationRadius: String = "illuminationRadius"
4✔
304
          val intensity: String = "intensity"
4✔
305
          val attenuation: String = "attenuation"
4✔
306

5✔
307
      object DynamicEntity:
UNCOV
308

×
309
        object Robot:
310
          val self: String = "robot"
3✔
311
          val radius: String = "radius"
8✔
312
          val speed: String = "speed"
4✔
313
          val withProximitySensors: String = "withProximitySensors"
4✔
314
          val withLightSensors: String = "withLightSensors"
4✔
315
          val behavior: String = "behavior"
4✔
316
    end Entity
5✔
317
  end Fields
318

319
  object Layout:
320
    val splitPaneWeight: Double = 0.8
×
321
    val splitPaneLocation: Double = 0.8
×
322

×
323
  object Frame:
324
    val minWidth = 800
×
325
    val minHeight = 600
×
326
    val prefWidth = 1200
×
UNCOV
327
    val prefHeight = 720
×
328
    val splitWeight = 0.8
×
329
    val canvasBorder: Int = 2
×
330

×
331
  object Canvas:
332
    val borderSize = 2
×
333
    val minZoom = 0.2
×
334
    val maxZoom = 5.0
×
335
    val zoomInFactor = 1.2
×
336
    val zoomOutFactor = 0.8
×
337
    val desiredLabelPixels = 40.0
×
338
    val gridStrokeWidth = 1f
×
339
    val labelDesiredPx: Double = 40.0
×
340
    val minLightSize: Int = 12
×
341
    val lightStroke: Float = 2f
×
UNCOV
342
    val labelBottomOffset: Int = 4
×
343
    val labelYOffset: Int = 12
×
344
    val labelXOffset: Int = 2
×
UNCOV
345

×
346
  object ControlsPanel:
UNCOV
347
    val startStopButtonText: String = "Start/Stop"
×
UNCOV
348

×
349
end SimulationDefaults
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc