int main(int argc, char **argv) {
    // Initialise node
    ros::init(argc, argv, "joint_state_publisher_fedar");
    // Initialise Nodehandler
    ros::NodeHandle nh;

    ros::Publisher jointPublisher = nh.advertise<sensor_msgs::JointState>("joint_states", 100);

    // Refresh rate
    ros::Rate loop_rate(30);

    motor_upper  = initializeMotor(108);
    motor_lower  = initializeMotor(109);

    while(ros::ok()) {
        jointPublish(jointPublisher);
        ros::spinOnce();
        loop_rate.sleep();
    }
}
Example #2
0
/*
 * main.c
 */
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;        // Stop watchdog timer

   initializeMotor();

   initializeADC10();
   P1DIR |= BIT0;
   P1DIR |= BIT6;

for (;;){
        leftSensorVoltage=getLeftSensorVoltage();

        if(leftSensorVoltage < LEFTDISTANCE){
                P1OUT &= ~BIT0;
                moveRobot(SMALLRIGHT);
        }
        else{
                P1OUT |= BIT0;
                moveRobot(FORWARD);
        }

        rightSensorVoltage=getRightSensorVoltage();

        if(rightSensorVoltage<RIGHTDISTANCE){
                P1OUT &= ~BIT6;
                moveRobot(SMALLLEFT);
        }
        else{
                P1OUT |= BIT6;
                moveRobot(FORWARD);
        }
}

return 0;

}
gui_003::gui_003(QWidget *parent)
	: QMainWindow(parent)
{
	ui.setupUi(this);
	
	GraphicsView = new QGraphicsView_( this);
	Scene = new QGraphicsScene( GraphicsView);
	Item = new QGraphicsPixmapItem();
	Player = new VideoPlayer( this);
	Motors = new MotorCommands( this);

	connect( Player, SIGNAL( sendFrame( QImage)), this, SLOT( onSendFrame( QImage)));
	connect( GraphicsView, SIGNAL( fastScroll( int)), this, SLOT( onFastScroll( int)));
	connect( GraphicsView, SIGNAL( highResolutionRegion( QRect)), this, SLOT( onHighResolutionRegion( QRect)));
	connect( this, SIGNAL( moveFocus( int)), Motors, SLOT( onMoveFocus( int)));
	connect( this, SIGNAL( moveX( int)), Motors, SLOT( onMoveX( int)));
	connect( this, SIGNAL( moveY( int)), Motors, SLOT( onMoveY( int)));
	
	this->setFixedSize(960, 700);
	ui.toolBar->setMovable( false);
	ui.toolBar_2->setMovable( false);
	ui.toolBar_3->setMovable( false);

	
	gui_003::setCentralWidget( GraphicsView);
	GraphicsView->setVerticalScrollBarPolicy( Qt::ScrollBarAlwaysOff);
	GraphicsView->setHorizontalScrollBarPolicy( Qt::ScrollBarAlwaysOff);
	
	ui.actionRGB->setCheckable( true);
	ui.actionLab->setCheckable( true);
	ui.actionCrossCursor->setCheckable( true);
	ui.actionRGB->setIcon( QIcon( "Resources/rgb.png"));
	ui.actionLab->setIcon( QIcon( "Resources/lab.png"));
	ui.actionCrossCursor->setIcon( QIcon( "Resources/cross.png"));
	ui.actionSave->setIcon( QIcon( "Resources/Save-icon.png"));
	ui.actionUp->setIcon( QIcon( "Resources/up.png"));
	ui.actionDown->setIcon( QIcon( "Resources/down.png"));
	ui.actionLeft->setIcon( QIcon( "Resources/reverse.png"));
	ui.actionRight->setIcon( QIcon( "Resources/forward.png"));

	QActionGroup* filter_group = new QActionGroup( this );
	ui.actionLab->setActionGroup( filter_group);
	ui.actionRGB->setActionGroup( filter_group);

	//position the horizontal movement controls
	QWidget* HorizontalSpacer = new QWidget();
	HorizontalSpacer->setFixedWidth( 330);
	ui.toolBar_3->addWidget( HorizontalSpacer);
	ui.toolBar_3->addAction( ui.actionLeft);
	ui.toolBar_3->addSeparator();
	ui.toolBar_3->addAction( ui.actionRight);

	//position the vertical movement controls
	QWidget* VerticalSpacer = new QWidget();
	VerticalSpacer->setFixedHeight( 210);
	ui.toolBar_2->addWidget( VerticalSpacer);
	ui.toolBar_2->addAction( ui.actionUp);	
	ui.toolBar_2->addSeparator();
	ui.toolBar_2->addAction( ui.actionDown);

	//position the main toolbar controls
	ui.toolBar->addAction( ui.actionSave);
	ui.toolBar->addAction( ui.actionCrossCursor);
	QWidget* maintoolbar_spacer = new QWidget();
	maintoolbar_spacer->setFixedWidth( 270);
	ui.toolBar->addWidget( maintoolbar_spacer);
	ui.toolBar->addAction( ui.actionRGB);
	ui.toolBar->addSeparator();
	ui.toolBar->addAction( ui.actionLab);

	//set cursor type over the main window parts
	ui.toolBar->setCursor( Qt::PointingHandCursor);
	ui.toolBar_2->setCursor( Qt::PointingHandCursor);
	ui.toolBar_3->setCursor( Qt::PointingHandCursor);

	//color scheme is default
	Player->LabImage = false;
	ui.actionRGB->setChecked( true);
	Player->start();

	//motors
	initializeMotor();

	//focus
	this->setFocus();
}