ArmWidget.h
Go to the documentation of this file.
00001 /****************************************************************************
00002 **
00003 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
00004 ** All rights reserved.
00005 ** Contact: Nokia Corporation (qt-info@nokia.com)
00006 **
00007 ** This file is part of the examples of the Qt Toolkit.
00008 **
00009 ** $QT_BEGIN_LICENSE:BSD$
00010 ** You may use this file under the terms of the BSD license as follows:
00011 **
00012 ** "Redistribution and use in source and binary forms, with or without
00013 ** modification, are permitted provided that the following conditions are
00014 ** met:
00015 **   * Redistributions of source code must retain the above copyright
00016 **     notice, this list of conditions and the following disclaimer.
00017 **   * Redistributions in binary form must reproduce the above copyright
00018 **     notice, this list of conditions and the following disclaimer in
00019 **     the documentation and/or other materials provided with the
00020 **     distribution.
00021 **   * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
00022 **     the names of its contributors may be used to endorse or promote
00023 **     products derived from this software without specific prior written
00024 **     permission.
00025 **
00026 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00027 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00028 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00029 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00030 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00031 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00032 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00033 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00034 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00035 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00036 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
00037 ** $QT_END_LICENSE$
00038 **
00039 ****************************************************************************/
00040 
00041 #ifndef ARMWIDGET_H
00042 #define ARMWIDGET_H
00043 
00044 #include <QtGui/QGraphicsView>
00045 #include "joint.h"
00046 
00047 static const double PIXELS_PER_METER = 200.0;
00048 
00049 
00050 double inchesToMeters(const double inches);
00051 double PixeltoMeter(const double pixel);
00052 double MetersToPixels(const double meters);
00053 
00054 
00055 typedef enum
00056 {
00057     Al5a, Pincher, Reactor, OldCorobot
00058 } armType;
00059 
00060 class ArmWidget : public QGraphicsView
00061  {
00062      Q_OBJECT
00063 
00064  public:
00065      ArmWidget(QWidget *parent = 0);
00066 
00067      void itemMoved();//timer starts if a movement is detected
00068      void moveArmUp();//moves the arm up
00069      void moveArmDown();//moves the arm down
00070      void moveArmLeft();//moves the arm toward the robot
00071      void moveArmRight();//moves the arm far from the robot
00072 
00073 
00074 
00075  public slots:
00076      void shoulder_degree(bool value);//if value is true, the signal theta1 will be emited in degrees
00077      void elbow_degree(bool value);//if value is true, the signal theta2 will be emited in degrees
00078      void received_pos(double x, double y);//set the position ofthe arm. x,y if he position in meters
00079      void Corobot(bool value);// value is true of a Corobot, false if is an Explorer, Explorer doesn't have an arm therefore the Widget is white
00080      void setModel(bool arm_al5a,bool arm_pincher,bool arm_reactor,bool arm_old_corobot); //set the model of the arm, and so the constants for the length of the parts of the arm
00081  signals:
00082      void theta1(double value); //shoulder angle in either degree or radian
00083      void theta2(double value); //elbow angle in either degree or radian
00084      void shoulderAngle_rad(double value);//shoulder angle in radian
00085      void elbowAngle_rad(double value); //elbow angle in radian
00086      void posarm(float x, float y); //position of the arm in meters
00087 
00088  protected:
00089      void timerEvent(QTimerEvent *event);//execute this function when the timer is up.
00090      void drawBackground(QPainter *painter, const QRectF &rect); // draw the widget background
00091 
00092  private:
00093      int timerId;
00094      QPointF end_effector;
00095      bool shoulder;
00096      bool elbow;
00097      armType arm_type;
00098 
00099  };
00100 
00101 
00102 
00103 #endif // ARMWIDGET_H
00104 


corobot_teleop
Author(s):
autogenerated on Sun Oct 5 2014 23:18:16