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

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

04 Sep 2025 08:29PM UTC coverage: 80.49% (+25.3%) from 55.207%
#583

push

github

GiuliaNardicchia
refactor: simplify comments in BehaviorTypes

1576 of 1958 relevant lines covered (80.49%)

11.1 hits per line

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

52.43
/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 Behaviors:
32

×
33
    object Prioritized:
34
      val DangerDist: Double = 0.40
3✔
35
      val LightThreshold: Double = 0.05
8✔
36

5✔
37
    object Phototaxis:
38
      val Epsilon: Double = 1e-9
3✔
39
      val MinForwardBias: Double = 0.4
8✔
40
      val TurnGain: Double = 1.0
4✔
41

5✔
42
    object ObstacleAvoidance:
43
      val CruiseSpeed: Double = 0.35
3✔
44
      val WarnSpeed: Double = 0.15
8✔
45
      val WarnTurnSpeed: Double = 0.55
4✔
46
      val BackBoost: Double = 0.20
4✔
47
      val SafeDist: Double = 0.5
4✔
48
      val CriticalDist: Double = 0.35
4✔
49

5✔
50
    object RandomWalk:
51
      val MinForwardFactor: Double = 0.35
3✔
52
      val MaxForwardExtra: Double = 0.35
8✔
53
      val MinTurnOfBase: Double = 0.35
4✔
54
      val MaxTurnOfBase: Double = 1.15
4✔
55
      val TurnExponent: Double = 1.2
4✔
56
      val PivotBoostProb: Double = 0.20
4✔
57
      val PivotBoostAbs: Double = 0.15
4✔
58

5✔
59
  end Behaviors
60

61
  object UI:
62

×
63
    object SimulationViewConstants:
64
      val IdDisplayLength = 8
×
65
      val PositionDecimals = 2
×
66
      val OrientationDecimals = 1
×
67
      val DefaultRobotInfo = "Select a robot to view details"
×
68
      val StopConfirmMessage = "Are you sure you want to stop the simulation?\n\nClick Yes to stop, No to continue."
×
69
      val StopConfirmTitle = "Stop Simulation"
×
70

×
71
    object Colors:
72
      @inline private def rgb(r: Int, g: Int, b: Int) = new java.awt.Color(r, g, b)
×
73
      @inline private def rgba(r: Int, g: Int, b: Int, a: Int) = new java.awt.Color(r, g, b, a)
×
74
      def backgroundLight: Color = rgb(250, 250, 250)
×
75
      def backgroundMedium: Color = rgb(245, 245, 245)
×
76
      def border: Color = rgb(200, 200, 200)
×
77
      def text: Color = rgb(60, 60, 60)
×
78
      def obstacleGradientStart: Color = rgb(120, 120, 120)
×
79
      def obstacleGradientEnd: Color = rgb(80, 80, 80)
×
80
      def obstacleBorder: Color = rgb(60, 60, 60)
×
81
      def robotDefault: Color = rgb(100, 150, 255)
×
82
      def robotDefaultDark: Color = rgb(50, 100, 200)
×
83
      def robotDefaultBorder: Color = rgb(0, 50, 150)
×
84
      def robotSelected: Color = rgb(255, 100, 100)
×
85
      def robotSelectedDark: Color = rgb(200, 50, 50)
×
86
      def robotSelectedBorder: Color = rgb(150, 0, 0)
×
87
      def robotShadow: Color = rgba(0, 0, 0, 50)
×
88
      def lightCenter: Color = rgba(255, 255, 200, 200)
×
89
      def lightEdge: Color = rgba(255, 140, 0, 80)
×
90
      def buttonHover: Color = rgb(230, 230, 230)
×
91
      def buttonPressed: Color = rgb(220, 235, 250)
×
92
      def timeDisplay: Color = rgb(50, 50, 50)
×
93

×
94
    end Colors
95

96
    object Fonts:
97
      val FontSize = 12
×
98
      val TitleSize = 12
×
99

×
100
    object Spacing:
101
      val StandardPadding = 10
×
102
      val InnerPadding = 5
×
103
      val ComponentGap = 10
×
104

×
105
    object Dimensions:
106
      val ButtonWidth = 150
×
107
      val ButtonHeight = 30
×
108
      val RobotListWidth = 250
×
109
      val RobotListHeight = 300
×
110
      val InfoAreaRows = 6
×
111
      val InfoAreaColumns = 25
×
112

×
113
    object Strokes:
114
      val ObstacleStroke = 1.5f
×
115
      val RobotShadowStroke = 3f
×
116

×
117
    object Icons:
118
      val Play = "\u25B6"
×
119
      val Stop = "\u23F9"
×
120
      val Pause = "\u23F8"
×
121
  end UI
×
122

123
  val Duration: Option[Long] = None
124
  val Seed: Option[Long] = None
8✔
125
  val DebugMode = false
4✔
126
  val BinarySearchDurationThreshold: FiniteDuration = 1.microseconds
4✔
127

15✔
128
  /**
129
   * Alternative light map configurations for different use cases
130
   */
131
  object LightMapConfigs:
132

3✔
133
    /**
134
     * Default light map with caching enabled Uses scale factor 10 for a good balance of performance and precision
135
     */
136
    lazy val BaseLightMap: LightMap[IO] =
137
      LightMap
11✔
138
        .create[IO](ScaleFactor.default, SquidLibFovEngine)
30✔
139
        .unsafeRunSync()
19✔
140

68✔
141
    /**
142
     * High-precision light map for detailed rendering Uses scale factor 100 for maximum precision.
143
     *
144
     * @return
145
     *   A [[io.github.srs.model.illumination.LightMap]] configured for high precision, or the default light map if the
146
     *   scale factor is invalid.
147
     */
148
    def HPLightMap: LightMap[IO] =
149
      ScaleFactor
×
150
        .validate(80)
×
151
        .map { scale =>
×
152
          LightMap
×
153
            .create[IO](scale, SquidLibFovEngine)
154
            .unsafeRunSync()
155
        }
156
        .getOrElse(BaseLightMap)
×
157

×
158
    /**
159
     * Fast light map for real-time simulation Uses scale factor 5 for maximum performance.
160
     *
161
     * @return
162
     *   A [[io.github.srs.model.illumination.LightMap]] configured for fast computation, or the default light map if
163
     *   the scale factor is invalid.
164
     */
165
    def fastLightMap: LightMap[IO] =
166
      ScaleFactor
×
167
        .validate(10)
×
168
        .map { scale =>
×
169
          LightMap
×
170
            .create[IO](scale, SquidLibFovEngine)
171
            .unsafeRunSync()
172
        }
173
        .getOrElse(BaseLightMap)
×
174

×
175
    /**
176
     * Custom light map with specific scale factor Curried for better composition.
177
     *
178
     * @param scaleFactor
179
     *   The desired scale factor (cells per meter).
180
     * @return
181
     *   A [[io.github.srs.model.illumination.LightMap]] configured with the specified scale factor, or the default
182
     *   light map if the scale factor is invalid.
183
     */
184
    def withScale(scaleFactor: Int): LightMap[IO] =
185
      ScaleFactor
×
186
        .validate(scaleFactor)
×
187
        .map { scale =>
×
188
          LightMap
×
189
            .create[IO](scale, SquidLibFovEngine)
190
            .unsafeRunSync()
191
        }
192
        .getOrElse(BaseLightMap)
×
193

×
194
  end LightMapConfigs
195

196
  object SimulationConfig:
197
    val MaxCount = 10_000
×
198

×
199
  object Environment:
200
    val DefaultWidth: Int = 10
3✔
201
    val MinWidth: Int = 1
8✔
202
    val MaxWidth: Int = 500
4✔
203

4✔
204
    val DefaultHeight: Int = 10
205
    val MinHeight: Int = 1
4✔
206
    val MaxHeight: Int = 500
4✔
207

4✔
208
    val DefaultEntities: Set[Entity] = Set.empty
209
    val MaxEntities: Int = 50
10✔
210

5✔
211
  object StaticEntity:
212

×
213
    object Obstacle:
214
      val DefaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000000")
3✔
215
      val DefaultPosition: Point2D = (0.0, 0.0)
13✔
216
      val DefaultOrientation: Orientation = Orientation(0.0)
8✔
217
      val DefaultWidth: Double = 1.0
10✔
218
      val DefaultHeight: Double = 1.0
4✔
219

5✔
220
    object Light:
221
      val DefaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000001")
3✔
222
      val DefaultPosition: Point2D = (0.0, 0.0)
13✔
223
      val DefaultOrientation: Orientation = Orientation(0.0)
8✔
224
      val DefaultRadius: Double = 0.05
10✔
225
      val DefaultIlluminationRadius: Double = 1.0
4✔
226
      val DefaultIntensity: Double = 1.0
4✔
227
      val DefaultAttenuation: Double = 1.0
4✔
228

5✔
229
    object Boundary:
230
      val DefaultPosition: Point2D = (0.0, 0.0)
3✔
231
      val DefaultOrientation: Orientation = Orientation(0.0)
12✔
232
      val DefaultWidth: Double = 1.0
10✔
233
      val DefaultHeight: Double = 1.0
4✔
234

5✔
235
  end StaticEntity
236

237
  object DynamicEntity:
238
    val ZeroSpeed: Double = 0.0
3✔
239
    val MinSpeed: Double = -1.0
8✔
240
    val MaxSpeed: Double = 1.0
4✔
241
    val HalfSpeed: Double = 0.5
4✔
242

5✔
243
    object Actuator:
244

×
245
      object DifferentialWheelMotor:
246
        val DefaultWheel: ActWheel = ActWheel()
3✔
247

22✔
248
        object Wheel:
249
          val DefaultSpeed: Double = 1.0
3✔
250
          val DefaultShape: ShapeType.Circle = ShapeType.Circle(0.1)
8✔
251
          val MinSpeed: Double = -1.0
6✔
252
          val MaxSpeed: Double = 1.0
4✔
253

5✔
254
    object Sensor:
255

×
256
      object ProximitySensor:
257
        val DefaultOffset: Double = 0.0
3✔
258
        val DefaultRange: Double = 1.0
8✔
259

5✔
260
    object Robot:
261

3✔
262
      val DefaultMaxRetries = 10
263

8✔
264
      val DefaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000002")
265
      val DefaultPosition: Point2D = (0.0, 0.0)
9✔
266
      val DefaultShape: ShapeType.Circle = ShapeType.Circle(0.25)
8✔
267
      val DefaultOrientation: Orientation = Orientation(0.0)
6✔
268
      val DefaultActuators: Seq[Actuator[Robot]] = Seq.empty
10✔
269
      val DefaultSensors: Vector[Sensor[Robot, Environment]] = Vector.empty
11✔
270
      val MinRadius: Double = 0.01
10✔
271
      val MaxRadius: Double = 0.5
4✔
272

4✔
273
      val SelectionStroke: Float = 3f
274
      val NormalStroke: Float = 1f
2✔
275
      val ArrowLengthFactor: Double = 0.6
2✔
276
      val ArrowWidthFactor: Double = 0.3
2✔
277
      val MinArrowWidth: Float = 2f
2✔
278

2✔
279
      val StdProximitySensors: Vector[Sensor[Robot, Environment]] = Vector(
280
        ProximitySensor(Orientation(0.0)),
6✔
281
        ProximitySensor(Orientation(45.0)),
26✔
282
        ProximitySensor(Orientation(90.0)),
18✔
283
        ProximitySensor(Orientation(135.0)),
18✔
284
        ProximitySensor(Orientation(180.0)),
18✔
285
        ProximitySensor(Orientation(225.0)),
18✔
286
        ProximitySensor(Orientation(270.0)),
18✔
287
        ProximitySensor(Orientation(315.0)),
18✔
288
      )
18✔
289

3✔
290
      val StdLightSensors: Vector[Sensor[Robot, Environment]] = Vector(
291
        LightSensor(Orientation(0.0)),
6✔
292
        LightSensor(Orientation(45.0)),
20✔
293
        LightSensor(Orientation(90.0)),
12✔
294
        LightSensor(Orientation(135.0)),
12✔
295
        LightSensor(Orientation(180.0)),
12✔
296
        LightSensor(Orientation(225.0)),
12✔
297
        LightSensor(Orientation(270.0)),
12✔
298
        LightSensor(Orientation(315.0)),
12✔
299
      )
12✔
300
      val DefaultPolicy: Policy = Policy.AlwaysForward
3✔
301
    end Robot
5✔
302
  end DynamicEntity
303

304
  object GridDSL:
305
    val ObstacleSize: Double = 0.999999
3✔
306
    val IncrementToCenterPos: Point2D = Point2D(0.5, 0.5)
8✔
307

12✔
308
  object Fields:
309

×
310
    object Simulation:
311
      val Self: String = "simulation"
3✔
312
      val Duration: String = "duration"
8✔
313
      val Seed: String = "seed"
4✔
314

5✔
315
    object Environment:
316
      val Self: String = "environment"
3✔
317
      val Width: String = "width"
8✔
318
      val Height: String = "height"
4✔
319
      val Entities: String = "entities"
4✔
320

5✔
321
    object Entity:
322
      val Id: String = "id"
3✔
323
      val Position: String = "position"
8✔
324
      val X: String = "x"
4✔
325
      val Y: String = "y"
2✔
326
      val Orientation: String = "orientation"
2✔
327

5✔
328
      object StaticEntity:
329

×
330
        object Obstacle:
331
          val Self: String = "obstacle"
3✔
332
          val Width: String = "width"
8✔
333
          val Height: String = "height"
4✔
334

5✔
335
        object Light:
336
          val Self: String = "light"
3✔
337
          val Radius: String = "radius"
8✔
338
          val IlluminationRadius: String = "illuminationRadius"
4✔
339
          val Intensity: String = "intensity"
4✔
340
          val Attenuation: String = "attenuation"
4✔
341

5✔
342
      object DynamicEntity:
343

×
344
        object Robot:
345
          val Self: String = "robot"
3✔
346
          val Radius: String = "radius"
8✔
347
          val Speed: String = "speed"
4✔
348
          val WithProximitySensors: String = "withProximitySensors"
4✔
349
          val WithLightSensors: String = "withLightSensors"
4✔
350
          val Behavior: String = "behavior"
4✔
351
    end Entity
5✔
352
  end Fields
353

354
  object Layout:
355
    val SplitPaneWeight: Double = 0.8
×
356
    val SplitPaneLocation: Double = 0.8
×
357

×
358
  object Frame:
359
    val MinWidth = 800
×
360
    val MinHeight = 600
×
361
    val PrefWidth = 1200
×
362
    val PrefHeight = 720
×
363
    val SplitWeight = 0.8
×
364
    val CanvasBorder: Int = 2
×
365

×
366
  object Canvas:
367
    val BorderSize = 2
×
368
    val MinZoom = 0.2
×
369
    val MaxZoom = 5.0
×
370
    val ZoomInFactor = 1.2
×
371
    val ZoomOutFactor = 0.8
×
372
    val DesiredLabelPixels = 40.0
×
373
    val GridStrokeWidth = 1f
×
374
    val LabelDesiredPx: Double = 40.0
×
375
    val MinLightSize: Int = 12
×
376
    val LightStroke: Float = 2f
×
377
    val LabelBottomOffset: Int = 4
×
378
    val LabelYOffset: Int = 12
×
379
    val LabelXOffset: Int = 2
×
380

×
381
    val LabelStepSequence: List[Int] = List(1, 2, 5)
382
    val LabelScaleBase: Int = 10
×
383
    val DiameterFactor: Double = 2.0
×
384

×
385
    object Sensors:
386
      val LineStrokeWidth: Float = 1.0f
×
387
      val DotSize: Int = 3
×
388

×
389
    object LightFX:
390

×
391
      val GradientFraction0: Float = 0f
392
      val GradientFraction1: Float = 0.55f
×
393
      val GradientFraction2: Float = 0.9f
×
394
      val GradientFraction3: Float = 1f
×
395

×
396
      val CoreFractionStart: Float = 0f
397
      val CoreFractionEnd: Float = 1f
×
398

×
399
      val GradientRadiusDivisor: Float = 2f
400
      val MinLightPixels: Int = 1
×
401
      val PostGlowAlpha: Float = 0.015f
×
402

×
403
      val RingStrokeWidth: Float = 0.8f
404
      val RingStrokeMiterLimit: Float = 10f
×
405
      val RingStrokeDash1: Float = 4f
×
406
      val RingStrokeDash2: Float = 6f
×
407
      val RingStrokeDashPhase: Float = 0f
×
408

×
409
      val GradientColor: Array[Color] = Array(
410
        new Color(255, 200, 0, 28),
×
411
        new Color(255, 180, 0, 16),
×
412
        new Color(255, 160, 0, 6),
×
413
        new Color(255, 140, 0, 0),
×
414
      )
×
415

×
416
    end LightFX
417

418
    object Arrow:
419
      val TriangleVertices: Int = 3
×
420

×
421
    object RobotBody:
422
      val GradientFractionStart: Float = 0f
×
423
      val GradientFractionEnd: Float = 1f
×
424

×
425
  end Canvas
426

427
  object ControlsPanel:
428
    val StartStopButtonText: String = "Start/Stop"
×
429

×
430
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