All Projects → FRC-Utilities → LibDS

FRC-Utilities / LibDS

Licence: MIT License
Library for controling FRC robots

Programming Languages

c
50402 projects - #5 most used programming language
C++
36643 projects - #6 most used programming language

Projects that are alternatives of or similar to LibDS

bht-ams-playerstage
Player/Stage SLAM
Stars: ✭ 35 (+20.69%)
Mutual labels:  robotics, control-systems
StuyLib
Award-Winning FRC Library by StuyPulse Team 694
Stars: ✭ 17 (-41.38%)
Mutual labels:  robotics, frc
EL6483 EmbeddedSystems
All course materials, build systems, etc. for the graduate Real-Time Embedded Systems Course, Spring 2017
Stars: ✭ 14 (-51.72%)
Mutual labels:  robotics, control-systems
Control Toolbox
The Control Toolbox - An Open-Source C++ Library for Robotics, Optimal and Model Predictive Control
Stars: ✭ 562 (+1837.93%)
Mutual labels:  robotics, control-systems
nn robustness analysis
Python tools for analyzing the robustness properties of neural networks (NNs) from MIT ACL
Stars: ✭ 36 (+24.14%)
Mutual labels:  robotics, control-systems
Qdriverstation
Cross-platform clone of the FRC Driver Station
Stars: ✭ 133 (+358.62%)
Mutual labels:  robotics, control-systems
interbotix ros manipulators
ROS Packages for Interbotix Arms
Stars: ✭ 32 (+10.34%)
Mutual labels:  robotics
LTVModels.jl
Tools to estimate Linear Time-Varying models in Julia
Stars: ✭ 14 (-51.72%)
Mutual labels:  control-systems
robo-vln
Pytorch code for ICRA'21 paper: "Hierarchical Cross-Modal Agent for Robotics Vision-and-Language Navigation"
Stars: ✭ 34 (+17.24%)
Mutual labels:  robotics
Google-Summer-of-Code-with-SymPy
This repository showcases my proposal, final report, and the work done during Google Summer of Code 2020 with the SymPy project.
Stars: ✭ 12 (-58.62%)
Mutual labels:  control-systems
MarsRoverHardware
PCB designs for the University of Waterloo Robotics Team
Stars: ✭ 61 (+110.34%)
Mutual labels:  robotics
smart grasping sandbox
A public sandbox for Shadow's Smart Grasping System
Stars: ✭ 69 (+137.93%)
Mutual labels:  robotics
Object-Goal-Navigation
Pytorch code for NeurIPS-20 Paper "Object Goal Navigation using Goal-Oriented Semantic Exploration"
Stars: ✭ 107 (+268.97%)
Mutual labels:  robotics
HRVO
The Hybrid Reciprocal Velocity Obstacle (C++)
Stars: ✭ 90 (+210.34%)
Mutual labels:  robotics
piper
No description or website provided.
Stars: ✭ 50 (+72.41%)
Mutual labels:  robotics
robotics-level-4
This repo contains projects created using TensorFlow-Lite on Raspberry Pi and Teachable Machine. AI and ML capabilities have been integrated with Robot's software.
Stars: ✭ 34 (+17.24%)
Mutual labels:  robotics
OPVO
Sample code of BMVC 2017 paper: "Visual Odometry with Drift-Free Rotation Estimation Using Indoor Scene Regularities"
Stars: ✭ 40 (+37.93%)
Mutual labels:  robotics
statbotics
📈 Modernizing Data Analytics for FRC Robotics
Stars: ✭ 20 (-31.03%)
Mutual labels:  frc
ign-math
General purpose math library for robot applications.
Stars: ✭ 35 (+20.69%)
Mutual labels:  robotics
awesome-industry4.0
Curated list of Industry 4.0 research, popular events, open-source software projects and learning resources that are worth looking into!
Stars: ✭ 57 (+96.55%)
Mutual labels:  robotics

LibDS

Build Status

The DriverStation library allows you to connect and manage a robot easily by providing an abstraction layer between an application and the network comununications between the robot and the host computer.

The library is written in C, allowing it to be used in many platforms and/or programming languages (using wrappers).

Features

LibDS implements the following features:

  • Modular design
  • Dynamic protocol loading
  • Integrated event system
  • Joystick handling functions
  • Safety features
  • Abstract-protocol object
  • Cross-platform socket handling

You may find a lot of mistakes here, be it design choices or just stupid mistakes. If you spot something, I would be very grateful if you could tell me about it (or make a pull request).

Example Projects

Image

I have created two example projects to demonstrate the uses of LibDS:

  • A command-line DS with SDL and ncurses/pdcurses
  • A graphical UI DS with Qt4/Qt5 and C++

You can browse the code of the examples here!

Quick Introduction

Initialization

The LibDS has its own event loop, which runs on a separate thread. To start the DS engine, you must call DS_Init(), which initializes all the modules of the LibDS (config, events, joysticks, etc).

You should initialize the DS before initalizing any of your application components that interact with the DS. Check this example:

#include <LibDS.h>

int main() {
   /* Initialize the DS */
   DS_Init();

   /* Now proceed to initializing your application */
   DeepMagic();
   VoodooInit();
   HeavyWizardry();
   
   /* Load the 2016 protocol, the protocol can be safely changed during runtime. 
    *
    * Also, the LibDS can operate safely without a loaded protocol, 
    * so there is no rush to call this function. 
    */
   DS_ConfigureProtocol (DS_GetProtocolFRC_2016());
}

Communication protocols

After initializing the DS, you must load a protocol, which instructs the LibDS on the following processes:

  • How to create client packets:

    • DS-to-robot packets
    • DS-to-radio packets
    • DS-to-FMS packets
  • How to read and interpret incoming packets

  • How to connect to the different network targets:

    • Input and output ports
    • IP protocol type (UDP or TCP)
    • Which IP addresses to use
  • Last but not least, the sender timings, for example:

    • Send DS-to-robot packets every 20 ms
    • Send DS-to-FMS packets every 500 ms
    • Do not send DS-to-radio packets

The LibDS has built-in support for the following protocols:

  • FRC 2009-2014
  • FRC 2015
  • FRC 2016 (same as 2015, but with different robot address)
  • FRC 2020 (in development)

To load a protocol, use the DS_ConfigureProtocol() function. As a final note, you can also implement your own protocols and instruct the LibDS to use it.

Interacting with the DS events

The LibDS registers the different events in a FIFO (First In, First Out) queue, to access the events, use the DS_PollEvent() function in a while loop. Each event has a "type" code, which allows you to know what kind of event are you dealing with.

The easiest way to react to the DS events is the following (pseudo-code):

DS_Event event;
while (DS_PollEvent (event)) {
   switch (event.type) {
      case DS_EVENT_X:
         // react to x event
      case DS_EVENT_Y:
         // react to y event
   }
}

The code above must be called periodically. Here is a (functional) example:

#include <LibDS.h>
#include <stdio.h>

static void process_events();

int main() {
   DS_Init();
   DS_ConfigureProtocol (DS_GetProtocolFRC_2016());
   
   while (1) {
      process_events();
      DS_Sleep (10);
   }
   
   return EXIT_SUCCESS;
}

void process_events() {
   DS_Event event;
   while (DS_PollEvent (&event)) {
      switch (event.type) {
      case DS_ROBOT_ENABLED:
         printf ("Robot enabled\n");
         break;
      case DS_ROBOT_DISABLED:
         printf ("Robot disabled\n");
         break;
      case DS_ROBOT_CONNECTED:
         printf ("Connected to robot\n");
         break;
      case DS_ROBOT_DISCONNECTED:
         printf ("Disconnected to robot\n");
         break;
      case DS_ROBOT_VOLTAGE_CHANGED:
         printf ("Robot voltage set to: %f\n", event.robot.voltage);
         break;
      default:
         break;
      }
   }
}

Project Architecture

'Private' vs. 'Public' members

  • All the functions that a client application would be interested in are located in DS_Client.h.

  • Functions that are used by the protocols to update the state of the LibDS are made available in DS_Config.h. Calling any of the 'setter' functions in DS_Config will trigger an event (which can later be used by the client application).

Protocols

Protocols are encapsulated structures. When a protocol is initialized, it defines its properties and its respective data functions. The different functions of the LibDS will then operate with the data and properties defined by the current protocol.

As with the original LibDS, protocols have access to the DS_Config to update the state of the LibDS.

The base protocol is implemented in the DS_Protocol structure.

Sockets

Instead of manually initializing a socket for each target, data direction and protocol type (UDP and TCP). The LibDS will use the DS_Socket object to define ports, protocol type and remote targets.

All the logic code is in socket.c, which will be in charge of managing the system sockets with the information given by a DS_Socket object.

Compilation instructions

To compile the project, navigate to the project root and run the following commands

  • qmake
  • make

To install compiled library files, and headers to the correct locations in /usr/local, use this command

  • sudo make install
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].