Center detected Marker by rotating kobuki Base

asked 2017-10-25 09:18:20 -0500

glukon gravatar image

updated 2017-10-25 09:21:54 -0500

Hi guys,

currently I'm working on a project where I detect a visual marker (square) with a monocular camera. The marker i am using is a two-colored square (a small yellow one centered inside a larger blue one). The camera itselfs is installed at the center point of a turtlebot2 wood-plate - but don't worry about that.

Now I have two moments of the found contours inside the image frame with coords centerOutX, centerOutY and centerInsX and centerInsY. The resolution I am currently using is quite large - 1280x720.

Assume diff = 0.5*(frame.rows) - 0.5*(self.cxOside + self.cxIside) and a status calledself.is_marker_detected and

    if self.is_marker_detected is False:

        self.vel_msg.angular.z = -0.3
        self.velocity_publisher.publish(self.vel_msg)

        # OpenCV Stuff and so on running here to detect the marker
        # Plus an if statement where I check the diff of the two moments intercepting
        # If so, marker is detected and the base should start with align to center

        diff = 640 - 0.5*(self.cxOside + self.cxIside)

              if diff == 0:
                    self.vel_msg.linear.x = 0.0
                    self.vel_msg.linear.y = 0.0
                    self.vel_msg.angular.z = abs(0.0)
                    self.velocity_publisher.publish(self.vel_msg)

                elif diff >= 0:
                    self.vel_msg.linear.x = 0.0
                    self.vel_msg.linear.y = 0.0
                    self.vel_msg.angular.z = abs(0.2)
                    self.velocity_publisher.publish(self.vel_msg)

                elif diff <= 0:
                    self.vel_msg.linear.x = 0.0
                    self.vel_msg.linear.y = 0.0
                    self.vel_msg.angular.z = -abs(0.2)
                    self.velocity_publisher.publish(self.vel_msg)

As you can see, I'm a bit overwhelmed cause I never did something like that. The problem here is that the base is not very exact and sometimes when there is to much rotation, status is_marker_detected turns into False and the robot starts to detect a marker again by rotating until it could be found.

Any suggestions or ideas?

edit retag flag offensive close merge delete