GithubHelp home page GithubHelp logo

go-kart-real-time-controller's Introduction

go-kart-real-time-controller's People

Contributors

haoruxue avatar rogerjangkim avatar ryentran avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

airacingtech

go-kart-real-time-controller's Issues

Packet API

What

To start on both the high-level and low level communication, we need:

  1. Define a series of struct/class to contain all the control, and feedback messages to be transmitted on the comm
  2. Define a serialization scheme for encoding/decoding the message into std::vector<uint8_t>, which can be easily transfered on any kind of comm: serial, CAN, ethernet.
  3. Provide a factory library for both MCU and onboard PC to encode and decode packets.
  4. Profile the serialization/deserialization to meet the control loop requirement.

Factory can't read one byte at

@HaoruXue suggests the reason probably is: "I suspect some vector iteration boundary condition may be broken with one byte"

The code where the issue appeared:
`void thread_comm_function()
{
auto packet_sub = myGkcPacketSubscriber();
packet_sub.set_actuator(&act);
auto factory = tritonai::gkc::GkcPacketFactory(&packet_sub, tritonai::gkc::GkcPacketUtils::debug_cout);
int bytes_read;

/*std::vector<uint8_t> recv_buffer(1, 0);
while (1)
{
    bytes_read = rs232.read(recv_buffer.data(), 1); //it reads one byte at a time
    if (bytes_read < 0)
        ;//error
    factory.Receive(recv_buffer);
}*/
std::vector<uint8_t> recv_buffer(2, 0);
while (1)
{
    for (int i = 0; i < 2; i++)
    {
        bytes_read = rs232.read(&(recv_buffer.data()[i]), 1); //it reads one byte at a 
        if (bytes_read < 0)
            ;//error
    }
    factory.Receive(recv_buffer);
}

}`

The commented version (1 byte) at a time doesn't work. But 2 bytes at a time and 3 bytes at a time work.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.