예제 #1
0
int16_t main(void) {
    // printf("Starting Rocket Controller...\r\n");
    init_clock();
    init_ui();
    init_pin();
    init_timer();
    init_i2c();
    setup();
    init_servo_driver(&sd1, &i2c3, 16000., 0x0);
    init_servo(&servo4, &sd1, 0);
    InitUSB();
    U1IE = 0xFF; //setting up ISR for USB requests
    U1EIE = 0xFF;
    IFS5bits.USB1IF = 0; //flag
    IEC5bits.USB1IE = 1; //enable
    // uint32_t pid_command;
    servo_set(&servo4, 1500, 0);
    while (1) {
        if (timer_flag(&timer1)) {
            // Blink green light to show normal operation.
            timer_lower(&timer1);
            led_toggle(&led2);
            // servo_set(&servo4, 1500, 0);
        }
    }
}
예제 #2
0
int main()
{
	create_connect();
	init_servo();


	//light_it_up(LIGHT_PORT);
	lightstart(LIGHT_PORT,120.0);

	create_full();
	create_drive_segment(HIGH_SPEED, -150);
	start_process(set_top);
	create_drive_arc(HIGH_SPEED, -200, 155);
	create_drive_segment(HIGH_SPEED, -365);
	create_drive_arc(HIGH_SPEED, 90, -64);
	create_drive_segment(HIGH_SPEED, -85);
	create_cease();
	set_top();
	align_twall();
	grab_top_de();
	create_spin_angle(400,-165);
	create_drive_segment(HIGH_SPEED, -320);
	//align_wall();
	create_stop();
	create_sync();
	dump_kelp_de();
	create_drive_segment(HIGH_SPEED,30);//go away from starting box
	create_spin_angle(HIGH_SPEED, -78);//turn to gate part 1
	create_drive_segment(HIGH_SPEED, 938);//go to gate
	create_drive_arc(HIGH_SPEED,185,84);//arc to gate
	//create_drive_time(HIGH_SPEED,1800);//go through the gate
	/*
	create_drive_segment(HIGH_SPEED,1470);
	create_drive_segment(HIGH_SPEED,-100);
	create_spin_angle(HIGH_SPEED,78);
	*/
	create_cease();
	create_drive_straight(HIGH_SPEED);//go onto oppponent's side of board
	msleep(1400);
	create_stop();
	create_arc(350,550);//arc to the opponent's mpa
	msleep(2500L);
	create_stop();//pause to keep the creat
	create_drive_straight(HIGH_SPEED);//go onto oppponent's side of board
	msleep(750);
	create_stop();
	create_drive_straight(-HIGH_SPEED);//go onto oppponent's side of board
	msleep(5000);
	create_stop();
	/*
	create_drive_segment(500,-500);//go past the IC
	create_drive_arc(320,-250,25);//arc to
	create_drive_arc(320,250,-8);
	*/
	//create_drive_segment(HIGH_SPEED,-750);
	//create_drive_arc(HIGH_SPEED,100,84);
	//create_drive_segment(HIGH_SPEED,1300);
}
예제 #3
0
int main(int argc, char* argv[])
{
    init_display();
    init_std_threads();
    init_servo();
    shutdown_std_threads();

    return 0;
}
예제 #4
0
void main(void)
{
	WDTCTL = WDTPW | WDTHOLD; // Stop watchdog timer
	init_LED();
	init_button();
	init_servo();
	TA0CTL=TASSEL_2 | ID_0 | MC_1;
	_BIS_SR(LPM0_bits | GIE);
}
예제 #5
0
/*!
 @brief Program entry point
 */
int main (void) {
	struct MagnetInit magnetInit;
	struct ServoInit boomServoInit, crowdServoInit, swingServoInit;
	struct RobotInit robotInit;
	
	magnetInit.periph = RCC_AHB1Periph_GPIOD;
	magnetInit.GPIOx = GPIOD;
	magnetInit.pin = GPIO_Pin_15;
	
	boomServoInit.CCR = 1;
	boomServoInit.maxPosition = BOOM_ANGLE_MAX;
	boomServoInit.minPosition = BOOM_ANGLE_MIN;
	
	crowdServoInit.CCR = 2;
	crowdServoInit.maxPosition = CROWD_ANGLE_MAX;
	crowdServoInit.minPosition = CROWD_ANGLE_MIN;
	
	swingServoInit.CCR = 3;
	swingServoInit.maxPosition = SWING_ANGLE_MAX;
	swingServoInit.minPosition = SWING_ANGLE_MIN;
	
	robotInit.boomServo = &boomServo;
	robotInit.crowdServo = &crowdServo;
	robotInit.swingServo = &swingServo;
	
	osThreadId tid_armThread;
	osThreadId tid_ledThread;

	init_TIM4(1 / SERVO_DUTY_CYCLE_STEP, SERVO_FREQUENCY);
	init_LEDS_PWM();
	init_LEDS();
	
	init_servo(&boomServo, &boomServoInit);
	init_servo(&crowdServo, &crowdServoInit);
	init_servo(&swingServo, &swingServoInit);
	init_robot(&robot, &robotInit);
	init_magnet(&magnet, &magnetInit);
	init_receiver(&receiver);
	
	tid_armThread = osThreadCreate(osThread(armThread), NULL);
	tid_ledThread = osThreadCreate(osThread(ledThread), NULL);
	
	osDelay(osWaitForever);
}
예제 #6
0
파일: main.cpp 프로젝트: nfarrow/honeycomb
// ============================================================================================
// for initialization of swarm dynamics function
// ============================================================================================
void init_common()
{
	int i;
	init_servo();
	for(i=0;i<NUM_NEIGHBORS;i++){
		mchip.neix[i] = 0.0;
		mchip.neiy[i] = 0.0;
		mchip.open[i] = false;
	}
}
예제 #7
0
파일: main.cpp 프로젝트: nfarrow/honeycomb
void reset(int num)
{
	reset_myself(num);
	init_servo();

	//send reset messege
	mdata.x = 0.0;	mdata.y = 0.0;	mdata.pnum = 50 + num;

	Xgrid::Packet pkt;
	pkt.type = 0;
	pkt.flags = 0;	
	pkt.radius = 14;
	pkt.data = (uint8_t *)&mdata;
	pkt.data_len = sizeof(point);
	xgrid.send_packet(&pkt,0b00111111);		// send to all neighbors
}
예제 #8
0
파일: Servo2D.cpp 프로젝트: Coder206/servo
// Initialize a Servo instance
int Servo2D::init() {

  ML_LOG(Debug, "Servo2D Initializing.");

  // Set up the prism
  createInitialPrism();
  lumin::ui::Cursor::SetScale(prism_, 0.03f);
  instanceInitialScenes();

  // Get the planar resource that holds the EGL context
  lumin::RootNode* root_node = prism_->getRootNode();
  if (!root_node) {
    ML_LOG(Error, "Servo2D Failed to get root node");
    abort();
    return 1;
  }

  std::string content_node_id = Servo2D_exportedNodes::content;
  content_node_ = lumin::QuadNode::CastFrom(prism_->findNode(content_node_id, root_node));
  if (!content_node_) {
    ML_LOG(Error, "Servo2D Failed to get content node");
    abort();
    return 1;
  }
  content_node_->setTriggerable(true);

  content_panel_ = lumin::ui::UiPanel::CastFrom(prism_->findNode(Servo2D_exportedNodes::contentPanel, root_node));
  if (!content_panel_) {
    ML_LOG(Error, "Servo2D Failed to get content panel");
    abort();
    return 1;
  }
  lumin::ui::UiPanel::RequestFocus(content_panel_);

  lumin::ResourceIDType plane_id = prism_->createPlanarEGLResourceId();
  if (!plane_id) {
    ML_LOG(Error, "Servo2D Failed to create EGL resource");
    abort();
    return 1;
  }

  plane_ = static_cast<lumin::PlanarResource*>(prism_->getResource(plane_id));
  if (!plane_) {
    ML_LOG(Error, "Servo2D Failed to create plane");
    abort();
    return 1;
  }

  content_node_->setRenderResource(plane_id);

  // Get the EGL context, surface and display.
  EGLContext ctx = plane_->getEGLContext();
  EGLSurface surf = plane_->getEGLSurface();
  EGLDisplay dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);

  // Hook into servo
  servo_ = init_servo(ctx, surf, dpy, this, logger, history, HOME_PAGE, VIEWPORT_W, VIEWPORT_H, HIDPI);
  if (!servo_) {
    ML_LOG(Error, "Servo2D Failed to init servo instance");
    abort();
    return 1;
  }

  // Add a callback to the back button
  std::string back_button_id = Servo2D_exportedNodes::backButton;
  back_button_ = lumin::ui::UiButton::CastFrom(prism_->findNode(back_button_id, root_node));
  if (!back_button_) {
    ML_LOG(Error, "Servo2D Failed to get back button");
    abort();
    return 1;
  }
  back_button_->onActivateSub(std::bind(traverse_servo, servo_, -1));

  // Add a callback to the forward button
  std::string fwd_button_id = Servo2D_exportedNodes::fwdButton;
  fwd_button_ = lumin::ui::UiButton::CastFrom(prism_->findNode(fwd_button_id, root_node));
  if (!fwd_button_) {
    ML_LOG(Error, "Servo2D Failed to get forward button");
    abort();
    return 1;
  }
  fwd_button_->onActivateSub(std::bind(traverse_servo, servo_, +1));

  // Add a callback to the URL bar
  std::string url_bar_id = Servo2D_exportedNodes::urlBar;
  url_bar_ = lumin::ui::UiTextEdit::CastFrom(prism_->findNode(url_bar_id, root_node));
  if (!url_bar_) {
    ML_LOG(Error, "Servo2D Failed to get URL bar");
    abort();
    return 1;
  }
  lumin::ui::KeyboardProperties keyboard_properties;
  keyboard_properties.keyboardZPosition = lumin::ui::KeyboardProperties::KeyboardZPosition::kVolumeCursorPlane;
  keyboard_properties.width = KEYBOARD_W;
  url_bar_->setKeyboardProperties(keyboard_properties);
  url_bar_->onFocusLostSub(std::bind(&Servo2D::urlBarEventListener, this));

  // Add the laser pointer
  laser_ = lumin::LineNode::CastFrom(prism_->findNode(Servo2D_exportedNodes::laser, root_node));
  if (!laser_) {
    ML_LOG(Error, "Servo2D Failed to get laser");
    abort();
    return 1;
  }

  return 0;
}