Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Help to simulate 2D robots
Forum Updated to NodeBB v4.3 + New Features

Help to simulate 2D robots

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 2 Posters 306 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    feri
    wrote on last edited by
    #1

    I am a beginner, I ask you for help because I would like to create a 2d simulator of a 3-wheeled robot.
    The environment where the robot moves is a 3-color .png image:
    Red = obstacle, Black = lines to follow, White = clear space.
    The sensors are cones (QShape) that move with the robot.
    I need to determine the closest point to the apex of the cone when the shape of the cone overlaps the red color (the point is in the overlapping part).
    In addition, I have to determine when certain points of the robot pass over black.
    I don't know how to process the images to determine the data I need.
    If you can give me some information, thank you.
    Greetings

    Pl45m4P 1 Reply Last reply
    0
    • F feri

      I am a beginner, I ask you for help because I would like to create a 2d simulator of a 3-wheeled robot.
      The environment where the robot moves is a 3-color .png image:
      Red = obstacle, Black = lines to follow, White = clear space.
      The sensors are cones (QShape) that move with the robot.
      I need to determine the closest point to the apex of the cone when the shape of the cone overlaps the red color (the point is in the overlapping part).
      In addition, I have to determine when certain points of the robot pass over black.
      I don't know how to process the images to determine the data I need.
      If you can give me some information, thank you.
      Greetings

      Pl45m4P Offline
      Pl45m4P Offline
      Pl45m4
      wrote on last edited by
      #2

      @feri

      You could start here:

      • https://doc.qt.io/qt-5/graphicsview.html

      If debugging is the process of removing software bugs, then programming must be the process of putting them in.

      ~E. W. Dijkstra

      1 Reply Last reply
      1
      • F Offline
        F Offline
        feri
        wrote on last edited by
        #3

        Thank you for your reply.
        I have already seen that document and I understand that if I have gods
        QGraphicsItem I can determine the intersection with:

        QPainterPath intersectedPath = tem1-> shape () -> intersected (item2-> shape ());

        I measure the distance between the points that make up the intersectedPath
        with the vertex of the triangle and take the smaller one.
        the triangle (Cone) of the sensors I create a QGraphicsItem also the points on the robot.
        What I didn't understand is how I get a QGraphicsItem or a shape with the red and black colors of the image.
        Greetings

        Pl45m4P 1 Reply Last reply
        0
        • F feri

          Thank you for your reply.
          I have already seen that document and I understand that if I have gods
          QGraphicsItem I can determine the intersection with:

          QPainterPath intersectedPath = tem1-> shape () -> intersected (item2-> shape ());

          I measure the distance between the points that make up the intersectedPath
          with the vertex of the triangle and take the smaller one.
          the triangle (Cone) of the sensors I create a QGraphicsItem also the points on the robot.
          What I didn't understand is how I get a QGraphicsItem or a shape with the red and black colors of the image.
          Greetings

          Pl45m4P Offline
          Pl45m4P Offline
          Pl45m4
          wrote on last edited by Pl45m4
          #4

          @feri said in Help to simulate 2D robots:

          What I didn't understand is how I get a QGraphicsItem or a shape with the red and black colors of the image.

          Use a QBrush and fill your item with your desired color. For 2 colors you could split the item in 2 subsections with two QPainters (one with red brush, one with black) and fill them separately.


          If debugging is the process of removing software bugs, then programming must be the process of putting them in.

          ~E. W. Dijkstra

          1 Reply Last reply
          1

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved