Example #1
0
 //! @brief  sends a stop command to sphero
 private void SendStopCommand()
 {
     if (m_sphero != null)
     {
         m_sphero.Roll(m_lastHeading, 0);
     }
 }
Example #2
0
        /*!
         * @brief	calibrate from the given @a point in relationship to m_calibrateRotationRoot
         * @param   point the point relative to the rotation root
         */
        private void CalibrateFromPoint(Point point)
        {
            float width  = (float)m_calibrateRotationRoot.ActualWidth;
            float height = (float)m_calibrateRotationRoot.ActualHeight;

            // move origin from the top left to the center with y-up and x-right
            Matrix matrix = new Matrix(
                1, 0,
                0, -1,
                -width / 2.0, height / 2.0);
            Point localPoint = matrix.Transform(point);

            float angle        = (float)Math.Atan2(localPoint.Y, localPoint.X);
            int   angleDegrees = (int)(angle * 180.0 / Math.PI);

            angleDegrees += 90;
            angleDegrees  = (angleDegrees + 360) % 360;
            angleDegrees  = 360 - angleDegrees;

            // apply the rotation to the ui
            m_rotation.Angle = angleDegrees;

            // preview the calibration and limit to 10 Hz
            long milliseconds = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;

            if ((milliseconds - m_lastCommandSentTimeMs) > 100)
            {
                m_sphero.Roll(angleDegrees, 0);
                m_lastCommandSentTimeMs = milliseconds;
            }
        }