//-------------------------------------------------------------- void ofApp::setup(){ // listen on the given port cout << "listening for osc messages on port " << PORT << "\n"; receiver.setup(PORT); current_msg_string = 0; mouseX = 0; mouseY = 0; mouseButtonState = ""; ofSetFrameRate(24); ofBackground(30, 30, 130); l1.setPosition(200, 300, 50); l2.setPosition(-200, -200, 50); dollHead = new DollHead(); tempPitch = tempYaw = tempRoll = 0; // pitch: 20.2041 heading: 0.343797 roll: 95.8658 listening = true; keyboardMotorTest = true; #ifdef ARDUINO_PRESENT arduino = Arduino(); arduino.setup(); #endif }
int main( int argc, char **argv ) { //ROS initialization and publisher/subscriber setup ros::init( argc, argv, "GPIO_Driver" ); ros::NodeHandle nh("~"); std::string hw_id; // Get parameters from .launch file or parameter server, or take defaults nh.param<std::string>( "hardware_id", hw_id, "/dev/ttyACM0" ); NewArduinoInterface Arduino( hw_id ); GpioDriver* gpio_input = new GpioDriver( &Arduino, INPUT_PIN ); GpioDriver* gpio_output = new GpioDriver( &Arduino, OUTPUT_PIN ); if( gpio_input->initialize() == false || gpio_output->initialize() == false ) { ROS_ERROR("Error initializing GPIO driver"); return -1; } ros::Rate loop_rate_Hz(10); loop_rate_Hz.sleep(); bool value = 1; bool value2 = 0; while( nh.ok() ) { if( !gpio_output->set( value ) ) { return -1; } value = !value; value2 = gpio_input->get( bosch_drivers_common::FLOATING ); ROS_INFO("Read value %i", value2); ros::spinOnce(); loop_rate_Hz.sleep(); } ROS_WARN( "Closing GPIO driver." ); return 0; }
int main( int argc, char **argv ) { //ROS initialization and publisher/subscriber setup ros::init( argc, argv, "Encoder_Driver" ); ros::NodeHandle nh("~"); std::string hw_id; // Get parameters from .launch file or parameter server, or take defaults nh.param<std::string>( "hardware_id", hw_id, "/dev/ttyACM0" ); ROS_INFO("Initializing Arduino"); NewArduinoInterface Arduino( hw_id ); Arduino.initialize(); ROS_INFO("Creating fast Encoder"); // create new encoder driver using pins 3 and 4 EncoderDriver* encoder_driver = new EncoderDriver( &Arduino , 4, 3 ); encoder_driver->invertOutput(); ROS_INFO("Initializing Encoder"); if( encoder_driver->initialize() == false) { ROS_ERROR("Error initializing encoder driver"); return -1; } ROS_INFO("Creating slow Encoder"); // create new encoder driver using pins 5 and 6 EncoderDriver* encoder_driver2 = new EncoderDriver( &Arduino , 5, 6 ); ROS_INFO("Initializing slow Encoder"); if( encoder_driver2->initialize() == false) { ROS_ERROR("Error initializing encoder driver"); return -1; } ros::Rate loop_rate_Hz(1); int64_t position, position2; ROS_INFO("Setting initial position"); encoder_driver->setPosition(0); encoder_driver2->setPosition(0); ROS_INFO("Start reading current position every second..."); while( nh.ok() ) { position = encoder_driver->getPosition(); position2 = encoder_driver2->getPosition(); ROS_INFO("Position1: %li Position2: %li", position, position2); ros::spinOnce(); loop_rate_Hz.sleep(); } ROS_WARN( "Closing encoder driver." ); return 0; }
WaterActuator::WaterActuator () : _arduino(Arduino(8083)) { }
TemperatureSensor::TemperatureSensor() : _arduino(Arduino(8086)) { }