Errors with JAUS++ tutorial program

0

I recently installed the JAUS++ (http://active-ist.sourceforge.net/jaus++.php) and Boost libraries in Microsoft Visual Studio 2012. I am trying to run the first JAUS++ tutorial, found here (http://active-ist.sourceforge.net/jaus++/examples/tutorial_01.html) but, during debugging, it runs into:

"Unhandled exception at at 0x77064598 in JausTest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0024F240."

Then, it creates a break point. Then, if I hit continue, it gives a second error:

"Unhandled exception at 0x647C51C4 (msvcr110.dll) in JausTest.exe: 0xC0000005: Access violation reading location 0x0000006C."

It seems to break on: "discoveryService = component.DiscoveryService();" because the next line, "discoveryService->SetSubsystemIdentification(JAUS::Subsystem::Vehicle, "Robot");", says that it will be the next line of code to execute upon resuming.

I'm surprised that it is doing this because I copied the code straight from the tutorial. I am wondering if something is possibly wrong with the libraries?

Any insight would be extremely appreciated.

Here are the debug messages

'JausTest.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Cannot find or open the PDB file.
First-chance exception at 0x77064598 in JausTest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0024FAA0.
First-chance exception at 0x77064598 in JausTest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0024F240.
First-chance exception at 0x77064598 in JausTest.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
Unhandled exception at at 0x77064598 in JausTest.exe: Microsoft C++ exception: std::bad_alloc at memory location 0x0024F240.
The program '[5192] JausTest.exe' has exited with code 0 (0x0).

Following is the code:

#include "stdafx.h"
#include <jaus/core/component.h>
#include <cxutils/keyboard.h>
#include <iostream>



int main(int argc, char* argv[])
{
    // Create a component.  By default a component
    // has all the services of the Core Service set:
    // - Transport (JUDP)
    // - Control
    // - Discovery
    // - Events
    // - Liveness
    // - Time
    // - Management
    JAUS::Component component;

    // The Transport service is used to send
    // and receive messages to other JAUS components.  All
    // other services use the Transport service.  The
    // default transport type for JAUS++ is UDP communication
    // using the JUDP class.

    // The Discovery service is used to find
    // other JAUS components and services on the 
    // network using the Transport service.  In JAUS++
    // Discovery will automatically find these components,
    // make connections to them, and keep track of what
    // services they have.

    //  The first thing we must do for a component is
    //  configure its identification.  This is done by
    //  using the Discovery Service.  Get a pointer
    //  to the service:
    JAUS::Discovery* discoveryService = NULL;
    //discoveryService = (JAUS::Discovery*)component.GetService(JAUS::Discovery::Name);
    //  Alternative method:
    discoveryService = component.DiscoveryService();

    // Set the type of subsystem the component is for.  Subsystem
    // types available are currently Vehicle, or OCU.  The string
    // name "Robot" represents the type or category of platform.
    // You must set the subsystem identification before you will be
    // able to initialize your component.
    discoveryService->SetSubsystemIdentification(JAUS::Subsystem::Vehicle,
                                                 "Robot");
    // You can also set identification information for the component
    // and node that it is on.
    discoveryService->SetNodeIdentification("Primary Computer");
    discoveryService->SetComponentIdentification("Baseline");

    // Now that we have setup our identification information we
    // can initialize our component.  First, create the
    // component ID.
    JAUS::Address componentID(1000, 1, 1);
    // Initialize!
    std::cout << "Initializing component...";
    if(component.Initialize(componentID) == false)
    {
        std::cout << "Failed to initialize component [" << componentID.ToString() << "]\n";
        return 0;
    }
    std::cout << "Success!\n";

    // Now go into your main computer loop until the
    // component has been told to shutdown.
    JAUS::Time::Stamp displayStatusTimeMs = JAUS::Time::GetUtcTimeMs();
    while(true)
    {
        // Let's check the "state" of our component. This
        // is done using the Management service.  
        // A component can be in the following states:
        // - Initialized
        // - Ready
        // - Standby
        // - Shutdown
        // - Failure
        // - Emergency
        JAUS::Management* managementService = NULL;
        //managementService = (JAUS::Management*)component.GetService(JAUS::Management::Name);
        // Alternative method:
        managementService = component.ManagementService();
        if(managementService->GetStatus() == JAUS::Management::Status::Shutdown)
        {
            // Exit program.
            break;
        }
        if(JAUS::Time::GetUtcTimeMs() - displayStatusTimeMs > 500)
        {
            std::cout << "======================================================\n";
            // Print status of the service.
            managementService->PrintStatus(); std::cout << std::endl;

            displayStatusTimeMs = JAUS::Time::GetUtcTimeMs();
        }

        if(CxUtils::GetChar() == 27)
        {
            break;
        }

        CxUtils::SleepMs(1);
    }

    // Shutdown your component completely.  Any
    // services added or belonging to the component
    // will be deleted.
    component.Shutdown();

    return 0;
}
c++
exception
visual-studio-2012
memory-leaks
jaus++
asked on Stack Overflow Jun 21, 2015 by JarlSagan1278

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0