0.1.6 Radar

This commit is contained in:
rob tillaart 2021-12-27 20:23:58 +01:00
parent 84c364e1e0
commit b0789477d2
11 changed files with 82 additions and 55 deletions

View File

@ -2,6 +2,10 @@ compile:
# Choosing to run compilation tests on 2 different Arduino platforms
platforms:
- uno
- leonardo
- due
- zero
# - due
# - zero
# - leonardo
- m4
- esp32
# - esp8266
# - mega2560

View File

@ -4,10 +4,14 @@ name: Arduino CI
on: [push, pull_request]
jobs:
arduino_ci:
runTest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: Arduino-CI/action@master
# Arduino-CI/action@v0.1.1
- uses: ruby/setup-ruby@v1
with:
ruby-version: 2.6
- run: |
gem install arduino_ci
arduino_ci.rb

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2013-2021 Rob Tillaart
Copyright (c) 2013-2022 Rob Tillaart
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,7 +1,6 @@
//
// FILE: radarDemo.ino
// AUTHOR: Rob Tillaart
// VERSION: 0.1.1
// PURPOSE: demo of the radar library
// DATE: 29-03-2015
// URL: https://github.com/RobTillaart/RADAR

View File

@ -1,7 +1,7 @@
# Syntax Coloring Map for runningAngle
# Syntax Colouring Map for runningAngle
# Datatypes (KEYWORD1)
# Data types (KEYWORD1)
runningAngle KEYWORD1
AngleType KEYWORD1

View File

@ -1,6 +1,6 @@
{
"name": "RADAR",
"keywords": "Pan,tilt,radar,ping",
"keywords": "Pan,tilt,radar,ping,position",
"description": "Arduino library for a pan tilt radar. Experimental",
"authors":
[
@ -15,8 +15,9 @@
"type": "git",
"url": "https://github.com/RobTillaart/RADAR"
},
"version": "0.1.5",
"version": "0.1.6",
"license": "MIT",
"frameworks": "arduino",
"platforms": "*"
"platforms": "*",
"headers": "radar.h"
}

View File

@ -1,5 +1,5 @@
name=RADAR
version=0.1.5
version=0.1.6
author=Rob Tillaart <rob.tillaart@gmail.com>
maintainer=Rob Tillaart <rob.tillaart@gmail.com>
sentence=Arduino library for a pan tilt radar.

View File

@ -1,16 +1,18 @@
//
// FILE: radar.cpp
// AUTHOR: Rob Tillaart
// VERSION: 0.1.5
// VERSION: 0.1.6
// PURPOSE: Arduino library for a pan tilt radar.
// URL: https://github.com/RobTillaart/RADAR
//
// HISTORY
// 0.1.00 2013-09-30 (?) outline
// 0.1.01 2015-03-06 updated some code, still not functional
// 0.1.2 2017-07-16 refactor & review
// 0.1.3 2020-07-06 refactor, clean up and some documentation
// 0.1.4 2021-01-07 arduino-ci, unit-test
// 0.1.5 2021-05-27 fix arduino-lint
// 0.1.4 2021-01-07 Arduino-CI, unit-test
// 0.1.5 2021-05-27 fix Arduino-lint
// 0.1.6 2021-12-27 Update library.json, readme, license, minor edits
#include "radar.h"
@ -60,7 +62,7 @@ int16_t RADAR::getPan()
uint32_t movement = round(duration * _panPerSecond * 0.001);
if ( abs(_pan - _prevPan) <= movement) return _pan;
// else estimate PAN by linear interpolation
// else estimate PAN by linear interpolation
if (_pan > _prevPan) return _prevPan + movement;
return _prevPan - movement;
}
@ -87,8 +89,8 @@ int16_t RADAR::getTilt()
uint32_t movement = round(duration * _tiltPerSecond * 0.001);
if (abs(_tilt - _prevTilt) <= movement) return _tilt;
// estimate TILT by linear interpolation
if (_tilt > _prevTilt) return _prevTilt + movement;
// estimate TILT by linear interpolation
if (_tilt > _prevTilt) return _prevTilt + movement;
return _prevTilt - movement;
}
@ -100,29 +102,29 @@ void RADAR::gotoPanTilt(const int16_t pan, const int16_t tilt)
}
bool RADAR::setPosition(const uint8_t n, const int16_t pan, const int16_t tilt)
bool RADAR::setPosition(const uint8_t index, const int16_t pan, const int16_t tilt)
{
if (n >= RADAR_POSITIONS) return false;
_panArray[n] = pan;
_tiltArray[n] = tilt;
if (index >= RADAR_POSITIONS) return false;
_panArray[index] = pan;
_tiltArray[index] = tilt;
return true;
}
bool RADAR::getPosition(const uint8_t n, int16_t & pan, int16_t & tilt)
bool RADAR::getPosition(const uint8_t index, int16_t & pan, int16_t & tilt)
{
if (n >= RADAR_POSITIONS) return false;
pan = _panArray[n];
tilt = _tiltArray[n];
if (index >= RADAR_POSITIONS) return false;
pan = _panArray[index];
tilt = _tiltArray[index];
return true;
}
bool RADAR::gotoPosition(const uint8_t n)
bool RADAR::gotoPosition(const uint8_t index)
{
if (n >= RADAR_POSITIONS) return false;
gotoPan(_panArray[n]);
gotoTilt(_tiltArray[n]);
if (index >= RADAR_POSITIONS) return false;
gotoPan(_panArray[index]);
gotoTilt(_tiltArray[index]);
return true;
}
@ -157,7 +159,8 @@ uint32_t RADAR::ping(const int16_t pan, const int16_t tilt)
}
// PRIVATE
// TODO distill private parts (getPan and getTilt share a lot
// TODO distil private parts (getPan and getTilt share a lot
// -- END OF FILE --

View File

@ -2,7 +2,7 @@
//
// FILE: radar.h
// AUTHOR: Rob Tillaart
// VERSION: see RADAR_LIB_VERSION
// VERSION: 0.1.6
// PURPOSE: Arduino library for a pan tilt radar.
// URL: https://github.com/RobTillaart/RADAR
@ -10,7 +10,7 @@
#include "Arduino.h"
#define RADAR_LIB_VERSION (F("0.1.5"))
#define RADAR_LIB_VERSION (F("0.1.6"))
// TODO # positions in a begin() or constructor?
@ -39,9 +39,9 @@ public:
// memory positions - store / recall?
uint8_t getMaxPositions() { return RADAR_POSITIONS; };
bool setPosition(const uint8_t idx, const int16_t pan, const int16_t tilt);
bool getPosition(const uint8_t idx, int16_t & pan, int16_t & tilt);
bool gotoPosition(const uint8_t idx);
bool setPosition(const uint8_t index, const int16_t pan, const int16_t tilt);
bool getPosition(const uint8_t index, int16_t & pan, int16_t & tilt);
bool gotoPosition(const uint8_t index);
void setHomePosition(const int16_t pan, const int16_t tilt);
void gotoHomePosition();
@ -53,21 +53,21 @@ public:
// TODO NIY
uint32_t ping();
uint32_t ping(const int16_t pan, const int16_t tilt);
private:
int16_t _pinPan;
int16_t _pinTilt;
int16_t _prevPan;
int16_t _pan;
int16_t _homePan;
uint32_t _lastPanTime;
int16_t _prevTilt;
int16_t _tilt;
int16_t _homeTilt;
uint32_t _lastTiltTime;
int16_t _panArray[RADAR_POSITIONS];
int16_t _tiltArray[RADAR_POSITIONS];

View File

@ -1,8 +1,11 @@
[![Arduino CI](https://github.com/RobTillaart/Radar/workflows/Arduino%20CI/badge.svg)](https://github.com/marketplace/actions/arduino_ci)
[![Arduino-lint](https://github.com/RobTillaart/RADAR/actions/workflows/arduino-lint.yml/badge.svg)](https://github.com/RobTillaart/RADAR/actions/workflows/arduino-lint.yml)
[![JSON check](https://github.com/RobTillaart/RADAR/actions/workflows/jsoncheck.yml/badge.svg)](https://github.com/RobTillaart/RADAR/actions/workflows/jsoncheck.yml)
[![License: MIT](https://img.shields.io/badge/license-MIT-green.svg)](https://github.com/RobTillaart/Radar/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/RobTillaart/Radar.svg?maxAge=3600)](https://github.com/RobTillaart/Radar/releases)
# Radar
Arduino library for a pan tilt radar based upon 2 servo's.
@ -11,22 +14,25 @@ Arduino library for a pan tilt radar based upon 2 servo's.
## Warning
**WARNING: not extensively tested**
There are stil a lot of things to be tested.
There are still a lot of things to be tested.
The example code is now working to show the concept.
## Description
radar is a concept library not elaborated yet that implements a Ping))) based Radar
with the use of two pan/tilt servo's. It was written after a question on the forum but
never finished or tested it. Still, it has some interesting concepts wrt determine
the position of pan/tilt while in progress.
Radar is a concept library (not elaborated) that implements a Ping))) based Radar
with the use of two pan and tilt servo's.
It was written after a question on the Arduino forum but never finished or tested it.
Still, it has some interesting concepts with respect to how to determine the position
of pan/tilt while the movements are in progress.
The idea is that one knows how fast the pan and tilt servos are working in degrees per second.
From that number and the start moment one can determine approximately its position.
Given its position while moving is interesting for radar purposes as one can determine e.g.
in which direction a ping is given and which distance belongs to which pair of angles.
in which direction a ping is given and therefore which distance belongs to which pair of angles.
Note: no active development
## Interface
@ -57,9 +63,9 @@ Note: no valid range checking or negative value check.
### memory positions - store / recall?
- **uint8_t getMaxPositions()**
- **bool setPosition(const uint8_t idx, const int16_t pan, const int16_t tilt)**
- **bool getPosition(const uint8_t idx, int16_t & pan, int16_t & tilt)**
- **bool gotoPosition(const uint8_t idx)**
- **bool setPosition(const uint8_t index, const int16_t pan, const int16_t tilt)**
- **bool getPosition(const uint8_t index, int16_t & pan, int16_t & tilt)**
- **bool gotoPosition(const uint8_t index)**
- **void setHomePosition(const int16_t pan, const int16_t tilt)**
- **void gotoHomePosition()**
@ -76,3 +82,14 @@ Note: no valid range checking or negative value check.
See examples
## Future
- improve documentation.
- test more (e.g. continuous servo versus 180 servo).
- add sketches.
- remember lastPing (angle pan tilt).
- check TODO's in code.
- single servo radar (Pan only) as derived class.
- dynamic allocation of position arrays.

View File

@ -33,11 +33,12 @@
#include <ArduinoUnitTests.h>
#include "radar.h"
#include "radar.h"
unittest_setup()
{
fprintf(stderr, "RADAR_LIB_VERSION: %s\n", (char *) RADAR_LIB_VERSION);
}
@ -51,7 +52,7 @@ unittest(test_new_operator)
assertEqualINF(exp(800));
assertEqualINF(0.0/0.0);
assertEqualINF(42);
assertEqualNAN(INFINITY - INFINITY);
assertEqualNAN(0.0/0.0);
assertEqualNAN(42);
@ -61,8 +62,6 @@ unittest(test_new_operator)
unittest(test_constructor)
{
fprintf(stderr, "VERSION: %s\n", RADAR_LIB_VERSION);
RADAR radar(10, 11);
assertEqual(10, radar.getMaxPositions());