robotology / icub-firmware-shared

Protocols and Other Stuff Used both by iCub Firmware and iCub Software
GNU Lesser General Public License v2.1
3 stars 16 forks source link

embot: imported embot::core + embot::tools from icub-firmware #32

Closed marcoaccame closed 4 years ago

marcoaccame commented 4 years ago

they are needed by embedded boards and in short they will be also needed by some repositories in icub-head which require to communicate to the embedded boards using the C++ classes in the embot library.

I have placed them below icub-firmware-shared/embot because there will be a further directory tree with eth protocol and possibly also a can protocol part.

for minimal use of embot::core, if you shall:

#include "embot_core.h"

extern void time1microsecond_init() 
{ 
    // what is required to enable it, may nothing 
}

extern embot::core::Time time1microsecond_get() 
{ 
    // any code which returns a monotonic value in usec
    // it can be for instance:
    // return osal_system_abstime_get();
    // return yarp::os::Time::now() * embot::core::time1second;
    // or a dummy implementation
    static volatile uint64_t tt = 0;
    return tt++;        
}

void example()
{
    constexpr embot::core::Config cfg { 
       embot::core::TimeConfig {time1microsecond_init, time1microsecond_get} 
    };

    embot::core::init(cfg);

    // now you can use embot 

    embot::core::Time timenow = embot::core::now();
    // etc.    
}

this PR is linked to a similar PR in icub-firmware from branch embot2share -> devel (see https://github.com/robotology/icub-firmware/pull/110) in which: