Exemplo n.º 1
0
/**
 * This is the callback for PTZ control in single user mode. The driver needs to press
 * the left bumper button to control the camera.
 */
void joyCallback(const sensor_msgs::Joy::ConstPtr& msg){
	//If the Left Button is Pressed
	if (msg->buttons[LEFT_BUTTON] >.1) {
		//If the start and select buttons are pressed, enable boom control
		if(msg->buttons[SELECT_BUTTON]>0 && msg->buttons[START_BUTTON]>0){
			if (msg->axes[D_PAD_UP_DOWN] > 0)
				sendVelocityMessage(boomMotor,3000);
			else if (msg->axes[D_PAD_UP_DOWN] < 0)
				sendVelocityMessage(boomMotor,-3000);
			else sendVelocityMessage(boomMotor,0);
		}
		//Joystick DPAD will control stepping of motors
		else if(msg->axes[D_PAD_UP_DOWN] != 0 || msg->axes[D_PAD_LEFT_RIGHT] !=0){
			if (msg->axes[D_PAD_UP_DOWN] > 0)
				sendPositionMessage(tiltMotor, -upDownStep, false);
			else if (msg->axes[D_PAD_UP_DOWN] < 0)
				sendPositionMessage(tiltMotor, upDownStep, false);
			if (msg->axes[D_PAD_LEFT_RIGHT] > 0)
				sendPositionMessage(panMotor, -leftRightStep, false);
			else if (msg->axes[D_PAD_LEFT_RIGHT] < 0)
				sendPositionMessage(panMotor, leftRightStep, false);
		}
		//Control velocities with joysticks
		else{
			if (msg->axes[LEFT_VERTICAL_AXIS] < 0){
				if(abs(tiltMotor.currentPosition - tiltMotor.maxValue)
						< abs(tiltMotor.homePos-tiltMotor.maxValue)*.1)
					 sendVelocityMessage(tiltMotor,0);
				else sendVelocityMessage(tiltMotor,(int)(msg->axes[LEFT_VERTICAL_AXIS]*-topSpeed));
			}
			else if (msg->axes[LEFT_VERTICAL_AXIS] >= 0){
				if(abs(tiltMotor.currentPosition - tiltMotor.minValue) <
						abs(tiltMotor.homePos-tiltMotor.minValue)*.1)
					sendVelocityMessage(tiltMotor,0);
				else sendVelocityMessage(tiltMotor,(int)(msg->axes[LEFT_VERTICAL_AXIS]*-topSpeed));
			}
			if (msg->axes[LEFT_HORIZONTAL_AXIS] < 0){
				if(abs(panMotor.currentPosition - panMotor.maxValue) <
						abs(panMotor.homePos-panMotor.maxValue)*.1)
					sendVelocityMessage(panMotor,0);
				else sendVelocityMessage(panMotor,(int)(msg->axes[LEFT_HORIZONTAL_AXIS]*-topSpeed));
			}
			else if (msg->axes[LEFT_HORIZONTAL_AXIS] >= 0){
				if(abs(panMotor.currentPosition - panMotor.minValue) <
						abs(panMotor.homePos-panMotor.minValue)*.1)
					sendVelocityMessage(panMotor,0);
				else sendVelocityMessage(panMotor,(int)(msg->axes[LEFT_HORIZONTAL_AXIS]*-topSpeed));
			}

		}
	}
	//Tell pan-tilt to stop if joystick message not meant for them
	else{
		if(panMotor.isHoming || tiltMotor.isHoming) return;
		sendVelocityMessage(panMotor,0);
		sendVelocityMessage(tiltMotor,0);
	}
}
MapController::MapController(Map* inputMap, QObject* parent) :
    QObject(parent),
    map(inputMap),
    buddiesLayerVisible(true),
    observationsLayerVisible(true),
    udpSocket(NULL),
    broadcastPort(45678),
    broadcastInterval(3000),
    simulator(),
    positionReportTimer(NULL),
    acceptPositionReports(true),
    acceptSpotReports(true),
    appConfigDialog(NULL),
    showOwnship(false),
    followOwnship(false),
    isMapReady(false),
    drawingOverlay(0),
    lastHeading(0.0),
    mouseState(MouseStateNone)
{
  if (QFile::exists("./route.gpx"))
    simulator.setGpxFile("./route.gpx");
  else
    simulator.setGpxFile(GPS_SIMULATION_FILE);

  simulator.setTimerInterval(40); // Warning: jumpy at some intervals (ex. 100)
  simulator.setPlaybackMultiplier(25);
  connect(&simulator, SIGNAL(positionUpdateAvailable(QPointF, double)), this, SLOT(handlePositionAvailable(QPointF, double)));

  readAppConfig();

  // create the messaging socket connection and hook up message receiving
  udpSocket = new QUdpSocket(this);
  udpSocket->bind(broadcastPort, QUdpSocket::DontShareAddress | QUdpSocket::ReuseAddressHint);
  connect(udpSocket, SIGNAL(readyRead()), this, SLOT(processPendingDatagrams()));

  //Timer to send the position report
  positionReportTimer = new QTimer(this);
  positionReportTimer->setInterval(1000);
  connect(positionReportTimer, SIGNAL(timeout()), this, SLOT(sendPositionMessage()));
  handleToggleBroadcastPosition(true);
  handleToggleShowMe(true);
  handleToggleFollowMe(true);  

  chemLightColorStr = "None";
}
Exemplo n.º 3
0
static void processMotion(WMDraggingInfo * info, WMPoint * mousePos)
{
	Window newDestination = findDestination(info, mousePos);

	W_DragSourceStopTimer();

	if (newDestination != XDND_DEST_WIN(info)) {
		recolorCursor(info, False);

		if (XDND_DEST_WIN(info) != None) {
			/* leaving a xdnd window */
			sendLeaveMessage(info);
		}

		XDND_DEST_WIN(info) = newDestination;
		XDND_DEST_ACTION(info) = None;
		XDND_NO_POS_ZONE(info).size.width = 0;
		XDND_NO_POS_ZONE(info).size.height = 0;

		if (newDestination != None) {
			/* entering a xdnd window */
			XDND_SOURCE_STATE(info) = idleState;
			storeDestinationProtocolVersion(info);

			if (!sendEnterMessage(info)) {
				XDND_DEST_WIN(info) = None;
				return;
			}

			W_DragSourceStartTimer(info);
		} else {
			XDND_SOURCE_STATE(info) = NULL;
		}
	} else {
		if (XDND_DEST_WIN(info) != None) {
			if (!sendPositionMessage(info, mousePos)) {
				XDND_DEST_WIN(info) = None;
				return;
			}

			W_DragSourceStartTimer(info);
		}
	}
}