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

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

28 Aug 2025 12:05AM UTC coverage: 45.097%. First build
#410

Pull #67

github

davidcohenDC
feat(alwaysForwardBehavior): add AlwaysForwardBehavior with decision logic
Pull Request #67: feat(obstacleAvoidance): implement obstacle avoidance behavior in policy

32 of 48 new or added lines in 8 files covered. (66.67%)

1136 of 2519 relevant lines covered (45.1%)

6.18 hits per line

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

58.14
/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 Behaviors:
NEW
23

×
24
    object ObstacleAvoidance:
25
      val SafeDist: Double = 0.85
3✔
26
      val CriticalDist: Double = 0.35
8✔
27
      val MinForward: Double = 0.20
4✔
28
      val PivotSpeedFactor: Double = 0.80
2✔
29
      val ResultantEps: Double = 1e-9
4✔
30
      val SideDeltaEps: Double = 1e-3
4✔
31
      val FallbackLeftDeg: Double = 90.0
4✔
32

5✔
33
    object RandomWalk:
34
      val MinForwardFactor: Double = 0.35
3✔
35
      val MaxForwardExtra: Double = 0.35
8✔
36
      val MinTurnOfBase: Double = 0.35
4✔
37
      val MaxTurnOfBase: Double = 1.15
4✔
38
      val TurnExponent: Double = 1.2
4✔
39
      val PivotBoostProb: Double = 0.20
4✔
40
      val PivotBoostAbs: Double = 0.15
4✔
41

5✔
42
  object UI:
43

×
44
    object SimulationViewConstants:
45
      val IdDisplayLength = 8
×
46
      val PositionDecimals = 2
×
47
      val OrientationDecimals = 1
×
48
      val DefaultRobotInfo = "Select a robot to view details"
×
49
      val StopConfirmMessage = "Are you sure you want to stop the simulation?\n\nClick Yes to stop, No to continue."
×
50
      val StopConfirmTitle = "Stop Simulation"
×
51

×
52
    object Colors:
53
      @inline private def rgb(r: Int, g: Int, b: Int) = new java.awt.Color(r, g, b)
×
54
      @inline private def rgba(r: Int, g: Int, b: Int, a: Int) = new java.awt.Color(r, g, b, a)
×
55
      def backgroundLight: Color = rgb(250, 250, 250)
×
56
      def backgroundMedium: Color = rgb(245, 245, 245)
×
57
      def border: Color = rgb(200, 200, 200)
×
58
      def text: Color = rgb(60, 60, 60)
×
59
      def obstacleGradientStart: Color = rgb(120, 120, 120)
×
60
      def obstacleGradientEnd: Color = rgb(80, 80, 80)
×
61
      def obstacleBorder: Color = rgb(60, 60, 60)
×
62
      def robotDefault: Color = rgb(100, 150, 255)
×
63
      def robotDefaultDark: Color = rgb(50, 100, 200)
×
64
      def robotDefaultBorder: Color = rgb(0, 50, 150)
×
65
      def robotSelected: Color = rgb(255, 100, 100)
×
66
      def robotSelectedDark: Color = rgb(200, 50, 50)
×
67
      def robotSelectedBorder: Color = rgb(150, 0, 0)
×
68
      def robotShadow: Color = rgba(0, 0, 0, 50)
×
69
      def lightCenter: Color = rgba(255, 255, 200, 200)
×
70
      def lightEdge: Color = rgba(255, 140, 0, 80)
×
71
      def buttonHover: Color = rgb(230, 230, 230)
×
72
      def buttonPressed: Color = rgb(220, 235, 250)
×
73
      def timeDisplay: Color = rgb(50, 50, 50)
×
74

×
75
    end Colors
76

77
    object Fonts:
78
      val fontSize = 12
×
79
      val titleSize = 12
×
80

×
81
    object Spacing:
82
      val standardPadding = 10
×
83
      val innerPadding = 5
×
84
      val componentGap = 10
×
85

×
86
    object Dimensions:
87
      val buttonWidth = 150
×
88
      val buttonHeight = 30
×
89
      val robotListWidth = 250
×
90
      val robotListHeight = 300
×
91
      val infoAreaRows = 6
×
92
      val infoAreaColumns = 25
×
93

×
94
    object Strokes:
95
      val obstacleStroke = 1.5f
×
96
      val robotShadowStroke = 3f
×
97

×
98
    object Icons:
99
      val play = "\u25B6"
×
100
      val stop = "\u23F9"
×
101
      val pause = "\u23F8"
×
102
  end UI
×
103

104
  val duration: Option[Long] = None
105
  val seed: Option[Long] = None
8✔
106
  val debugMode = true
4✔
107
  val binarySearchDurationThreshold: FiniteDuration = 1.microseconds
2✔
108
  val lightMap: LightMap[IO] = LightMap.create[IO](SquidLibFovEngine, ScaleFactor.default).unsafeRunSync()
12✔
109

36✔
110
  object SimulationConfig:
111
    val maxCount = 10_000
×
112

×
113
  object Environment:
114
    val defaultWidth: Int = 10
3✔
115
    val minWidth: Int = 1
8✔
116
    val maxWidth: Int = 500
4✔
117

4✔
118
    val defaultHeight: Int = 10
119
    val minHeight: Int = 1
4✔
120
    val maxHeight: Int = 500
4✔
121

4✔
122
    val defaultEntities: Set[Entity] = Set.empty
123
    val maxEntities: Int = 200
10✔
124

5✔
125
  object StaticEntity:
126

×
127
    object Obstacle:
128
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000000")
3✔
129
      val defaultPosition: Point2D = (0.0, 0.0)
13✔
130
      val defaultOrientation: Orientation = Orientation(0.0)
8✔
131
      val defaultWidth: Double = 1.0
10✔
132
      val defaultHeight: Double = 1.0
4✔
133

5✔
134
    object Light:
135
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000001")
3✔
136
      val defaultPosition: Point2D = (0.0, 0.0)
13✔
137
      val defaultOrientation: Orientation = Orientation(0.0)
8✔
138
      val defaultRadius: Double = 0.05
10✔
139
      val defaultIlluminationRadius: Double = 1.0
4✔
140
      val defaultIntensity: Double = 1.0
4✔
141
      val defaultAttenuation: Double = 1.0
4✔
142

5✔
143
    object Boundary:
144
      val defaultPosition: Point2D = (0.0, 0.0)
3✔
145
      val defaultOrientation: Orientation = Orientation(0.0)
12✔
146
      val defaultWidth: Double = 1.0
10✔
147
      val defaultHeight: Double = 1.0
4✔
148

5✔
149
  end StaticEntity
150

151
  object DynamicEntity:
152
    val zeroSpeed: Double = 0.0
3✔
153
    val MinSpeed: Double = -1.0
8✔
154
    val MaxSpeed: Double = 1.0
4✔
155
    val halfSpeed: Double = 0.5
4✔
156

5✔
157
    object Actuator:
158

×
159
      object DifferentialWheelMotor:
160
        val defaultWheel: ActWheel = ActWheel()
3✔
161

22✔
162
        object Wheel:
163
          val defaultSpeed: Double = 1.0
3✔
164
          val defaultShape: ShapeType.Circle = ShapeType.Circle(0.1)
8✔
165

7✔
166
    object Sensor:
167

×
168
      object ProximitySensor:
169
        val defaultOffset: Double = 0.0
×
170
        val defaultRange: Double = 5.0
×
171

×
172
    object Robot:
173
      import SimulationDefaults.DynamicEntity.Robot.defaultShape.radius
3✔
174

175
      val defaultMaxRetries = 10
176

6✔
177
      val defaultId: UUID = UUID.fromString("00000000-0000-0000-0000-000000000002")
178
      val defaultPosition: Point2D = (0.0, 0.0)
9✔
179
      val defaultShape: ShapeType.Circle = ShapeType.Circle(0.5)
8✔
180
      val defaultOrientation: Orientation = Orientation(0.0)
6✔
181
      val defaultActuators: Seq[Actuator[Robot]] = Seq.empty
10✔
182
      val defaultSensors: Vector[Sensor[Robot, Environment]] = Vector.empty
11✔
183

10✔
184
      val selectionStroke: Float = 3f
185
      val normalStroke: Float = 1f
2✔
186
      val arrowLengthFactor: Double = 0.6
2✔
187
      val arrowWidthFactor: Double = 0.3
2✔
188
      val minArrowWidth: Float = 2f
2✔
189

2✔
190
      val stdProximitySensors: Vector[Sensor[Robot, Environment]] = Vector(
191
        ProximitySensor(Orientation(0.0), radius),
6✔
192
        ProximitySensor(Orientation(45.0), radius),
23✔
193
        ProximitySensor(Orientation(90.0), radius),
15✔
194
        ProximitySensor(Orientation(135.0), radius),
15✔
195
        ProximitySensor(Orientation(180.0), radius),
15✔
196
        ProximitySensor(Orientation(225.0), radius),
15✔
197
        ProximitySensor(Orientation(270.0), radius),
15✔
198
        ProximitySensor(Orientation(315.0), radius),
15✔
199
      )
15✔
200

3✔
201
      val stdLightSensors: Vector[Sensor[Robot, Environment]] = Vector(
202
        LightSensor(Orientation(0.0)),
6✔
203
        LightSensor(Orientation(45.0)),
20✔
204
        LightSensor(Orientation(90.0)),
12✔
205
        LightSensor(Orientation(135.0)),
12✔
206
        LightSensor(Orientation(180.0)),
12✔
207
        LightSensor(Orientation(225.0)),
12✔
208
        LightSensor(Orientation(270.0)),
12✔
209
        LightSensor(Orientation(315.0)),
12✔
210
      )
12✔
211
      val defaultPolicy: Policy = Policy.AlwaysForward
3✔
212
    end Robot
5✔
213
  end DynamicEntity
214

215
  object Fields:
216

×
217
    object Simulation:
218
      val self: String = "simulation"
3✔
219
      val duration: String = "duration"
8✔
220
      val seed: String = "seed"
4✔
221

5✔
222
    object Environment:
223
      val self: String = "environment"
3✔
224
      val width: String = "width"
8✔
225
      val height: String = "height"
4✔
226
      val entities: String = "entities"
4✔
227

5✔
228
    object Entity:
229
      val id: String = "id"
3✔
230
      val position: String = "position"
8✔
231
      val x: String = "x"
4✔
232
      val y: String = "y"
2✔
233
      val orientation: String = "orientation"
2✔
234

5✔
235
      object StaticEntity:
236

×
237
        object Obstacle:
238
          val self: String = "obstacle"
3✔
239
          val width: String = "width"
8✔
240
          val height: String = "height"
4✔
241

5✔
242
        object Light:
243
          val self: String = "light"
3✔
244
          val radius: String = "radius"
8✔
245
          val illuminationRadius: String = "illuminationRadius"
4✔
246
          val intensity: String = "intensity"
4✔
247
          val attenuation: String = "attenuation"
4✔
248

5✔
249
      object DynamicEntity:
250

×
251
        object Robot:
252
          val self: String = "robot"
3✔
253
          val radius: String = "radius"
8✔
254
          val speed: String = "speed"
4✔
255
          val withProximitySensors: String = "withProximitySensors"
4✔
256
          val withLightSensors: String = "withLightSensors"
4✔
257
          val behavior: String = "behavior"
4✔
258
    end Entity
5✔
259
  end Fields
260

261
  object Layout:
262
    val splitPaneWeight: Double = 0.8
×
263
    val splitPaneLocation: Double = 0.8
×
264

×
265
  object Frame:
266
    val minWidth = 800
×
267
    val minHeight = 600
×
268
    val prefWidth = 1200
×
269
    val prefHeight = 720
×
270
    val splitWeight = 0.8
×
271
    val canvasBorder: Int = 2
×
272

×
273
  object Canvas:
274
    val borderSize = 2
×
275
    val minZoom = 0.2
×
276
    val maxZoom = 5.0
×
277
    val zoomInFactor = 1.2
×
278
    val zoomOutFactor = 0.8
×
279
    val desiredLabelPixels = 40.0
×
280
    val gridStrokeWidth = 1f
×
281
    val labelDesiredPx: Double = 40.0
×
282
    val minLightSize: Int = 12
×
283
    val lightStroke: Float = 2f
×
284
    val labelBottomOffset: Int = 4
×
285
    val labelYOffset: Int = 12
×
286
    val labelXOffset: Int = 2
×
287

×
288
  object ControlsPanel:
289
    val startStopButtonText: String = "Start/Stop"
×
290

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