view main/robots/odr/CruisingTask.cpp @ 221:8e6ca2ead01a main

Latest updates.
author Bob Cook <bob@bobcookdev.com>
date Mon, 09 Sep 2013 20:03:31 -0700
parents e23198d929e9
children
line wrap: on
line source

// ----------------------------------------------------------------------------------------
//
//  robots/odr/CruisingTask.cpp
//    
//  Bob Cook Development, Robotics Library
//  http://www.bobcookdev.com/rl/
//
//  Subsumption task to drive straight forward. Lowest priority task.
//
//  Copyright (c) 2011 Bob Cook
//
//  Permission is hereby granted, free of charge, to any person obtaining a copy
//  of this software and associated documentation files (the "Software"), to deal
//  in the Software without restriction, including without limitation the rights
//  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
//  copies of the Software, and to permit persons to whom the Software is
//  furnished to do so, subject to the following conditions:
//
//  The above copyright notice and this permission notice shall be included in
//  all copies or substantial portions of the Software.
//
//  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
//  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
//  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
//  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
//  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
//  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
//  THE SOFTWARE.
//
// ----------------------------------------------------------------------------------------

#include "CruisingTask.h"

#include "MotorsAndServos.h"
#include "Scoreboard.h"

// ----------------------------------------------------------------------------------------

CruisingTask::CruisingTask( const std::string& loggerName )
    : TaskObject( loggerName ),
      m_lastMessageTime()
{
}

// ----------------------------------------------------------------------------------------

CruisingTask::~CruisingTask()
{
}

// ----------------------------------------------------------------------------------------

void CruisingTask::update()
{
    // nothing to do here
}

// ----------------------------------------------------------------------------------------

bool CruisingTask::wantsControl()
{
    return true; // always wants control, should be lowest priority
}

// ----------------------------------------------------------------------------------------

void CruisingTask::takeControl()
{
    if ( m_lastMessageTime.isElapsed( TaskObject::TwoSeconds ) )
    {
        Scoreboard::sendManagerMessage( "Cruising" );
        m_lastMessageTime.update();
    }

    MotorsAndServos::servoPositions( 0, 0 );

    int8_t speed = Scoreboard::navMaximumSpeed();
    MotorsAndServos::motorSpeeds( speed, speed );
}

// ----------------------------------------------------------------------------------------