Message Boards Message Boards

[WSS22] 2D simulator for differential robots in The Wolfram Language

Posted 1 year ago

POSTED BY: Carlos Vidal
2 Replies

So yeah you're @Carlos Vidal in the project that is, creating a 2d simulator and here's the simulation of an obstacle working with a robot to get picked up.

drawState[arena_Rectangle, robotPosition : {_, _}, 
  obstaclePosition : {_, _}] := Graphics[{FaceForm[LightGray],
   EdgeForm[Blue],
   arena,
   FaceForm[Pink],
   EdgeForm[Orange],
   Rectangle[{96, 46}, {104, 54}],
   PointSize[.05],
   Point[robotPosition, VertexColors -> {Cyan}],
   PointSize[0.03],
   Point[obstaclePosition, VertexColors -> {Black, Red}]}]
DynamicModule[{x = 0, y = 25, 
  obstaclePosition = {RandomInteger[100], 25}},
 Dynamic@EventHandler[
   Dynamic[
    If[Norm[{x, y} - obstaclePosition] <= 1, 
     obstaclePosition = {x, y}]; 
    drawState[Rectangle[{0, 0}, {100, 50}], {x, y}, obstaclePosition]],
   {"UpArrowKeyDown" :> (If[y < 50, (y += 1)]),
    "DownArrowKeyDown" :> (If[y > 0, (y -= 1)]),
    "LeftArrowKeyDown" :> (If[x > 0, (x -= 1)]),
    "RightArrowKeyDown" :> (If[x < 100, (x += 1)])}]]

The various robot movements linear or circular, those are the kinds of movements that a robot makes finally @Carlos Vidal you made my fantasy come true: the robot performs a linear routine and if it encounters an obstacle that is the safe area, and I can't wait.

Dynamic 2d Simulator

This is Graphics and ListAnimate functions and the robot can also be controlled using keyboard keys and I'm shouting yeah because of the movement with or without obstacles, in which the robot can continue with its linear routine and create these simulations in the Wolfram Language.

POSTED BY: Dean Gladish

enter image description here -- you have earned Featured Contributor Badge enter image description here Your exceptional post has been selected for our editorial column Staff Picks http://wolfr.am/StaffPicks and Your Profile is now distinguished by a Featured Contributor Badge and is displayed on the Featured Contributor Board. Thank you!

POSTED BY: Moderation Team
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract