Skip to content

Commit

Permalink
Merge pull request #861 from glowmouse/develop
Browse files Browse the repository at this point in the history
Bee Focuser Device Driver
  • Loading branch information
knro committed Mar 4, 2019
2 parents 09a34c1 + 8146d1a commit 02d3964
Show file tree
Hide file tree
Showing 35 changed files with 5,007 additions and 0 deletions.
7 changes: 7 additions & 0 deletions 3rdparty/CMakeLists.txt
Expand Up @@ -98,6 +98,7 @@ option(WITH_ATIK "Install Atik Driver" On)
option(WITH_TOUPCAM "Install Toupcam Driver" On)
option(WITH_ALTAIRCAM "Install Altair Driver" On)
option(WITH_AVALON "Install Avalon StarGO Driver" On)
option(WITH_BEEFOCUS "Install Bee Focuser Driver" On)

find_package(FFmpeg)

Expand Down Expand Up @@ -279,6 +280,12 @@ SET(LIBRARIES_FOUND FALSE)
endif (ALTAIRCAM_FOUND)
endif (WITH_ALTAIRCAM)

## Bee Focuser
if (WITH_BEEFOCUS)
add_subdirectory(indi-beefocus)
endif(WITH_BEEFOCUS)


## INOVA
if (WITH_INOVAPLX)
find_package(INOVASDK)
Expand Down
84 changes: 84 additions & 0 deletions 3rdparty/indi-beefocus/CMakeLists.txt
@@ -0,0 +1,84 @@
cmake_minimum_required(VERSION 2.8)
PROJECT(indi_beefocus CXX C)

LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/")
LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../cmake_modules/")
include(GNUInstallDirs)

find_package(INDI REQUIRED)

set(BEEFOCUS_VERSION_MAJOR 1)
set(BEEFOCUS_VERSION_MINOR 0)

set(INDI_DATA_DIR "${CMAKE_INSTALL_PREFIX}/share/indi")

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/indi_beefocus.xml.cmake ${CMAKE_CURRENT_BINARY_DIR}/indi_beefocus.xml )

include_directories(${CMAKE_CURRENT_BINARY_DIR})
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/driver)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/firmware)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/glue)
include_directories(${INDI_INCLUDE_DIR})

include(CMakeCommon)

################# Beefocus ############################

set(indi_beefocus_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/driver/beefocus.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver/beeconnect.cpp
${CMAKE_CURRENT_SOURCE_DIR}/driver/beesimfirmware.cpp
${CMAKE_CURRENT_SOURCE_DIR}/firmware/command_parser.cpp
${CMAKE_CURRENT_SOURCE_DIR}/firmware/focuser_state.cpp
${CMAKE_CURRENT_SOURCE_DIR}/firmware/hardware_interface.cpp
)

add_executable(indi_beefocus ${indi_beefocus_SRCS})

target_link_libraries(indi_beefocus ${INDI_LIBRARIES} )

install(TARGETS indi_beefocus RUNTIME DESTINATION bin )

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/indi_beefocus.xml DESTINATION ${INDI_DATA_DIR})

################# Unit Testing ########################

IF (INDI_BUILD_UNITTESTS)
# Workaround for fixing a linking error caused by "-pie" flag in CMakeCommon
# set(CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nodump -Wl,-z,noexecstack -Wl,-z,relro -Wl,-z,now")

enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIRS})

SET(UNIT_TESTS
test_driver
)

foreach( TEST ${UNIT_TESTS} )
SET( TEST_SOURCES ${indi_beefocus_SRCS} ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/test_helpers.cpp )
SET( TEST_MAIN_CPP ${CMAKE_CURRENT_SOURCE_DIR}/unit_tests/${TEST}.cpp)
SET_SOURCE_FILES_PROPERTIES(${TEST_MAIN_CPP} PROPERTIES LANGUAGE CXX)

ADD_EXECUTABLE(${TEST} ${TEST_MAIN_CPP} ${TEST_SOURCES})

TARGET_LINK_LIBRARIES( ${TEST}
${INDI_LIBRARIES}
${GTEST_BOTH_LIBRARIES}
${CMAKE_THREAD_LIBS_INIT}
#${ZLIB_LIBRARY}
)
add_test( run-tests ${TEST} )

ADD_CUSTOM_COMMAND(
TARGET ${TEST}
COMMENT "Running ${TEST}"
POST_BUILD
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMAND ${TEST} )

endforeach(TEST)

ENDIF (INDI_BUILD_UNITTESTS)


59 changes: 59 additions & 0 deletions 3rdparty/indi-beefocus/README.md
@@ -0,0 +1,59 @@
Beefocus
========

Beefocus is an Open Source Hardware/ Software Telescope Focuser
The goal of the project is to create a high quality DIY focuser that's
relatively easy to build and modify.

The Github page for the project is https://github.com/glowmouse/beefocus
The page contains the focuser's firmware and hardware builds.

The connection to the focuser hardware is done using WiFi. WiFi telescope
setups are becoming common as astronomers mount computers directly onto
their telescopes to reduce cabling. The WiFi connection means one less cable
and one less USB port.

The Focuser's firmware runs on an ESP8266 - these are <$10 micro-controllers
similar to Arduinos (in fact, the Arduino SDK is used to compile the firmware)

Actual and Simulated Focuser
============================

The Beefocus INDI driver supports two modes,

1. Connect to an actual focuser using a TCP/IP connection
2. Simulate the focuser in software, using a virtual "software-only" connection

The actual hardware focuser is controlled by firmware that's compiled and
loaded onto the EPS8266 micro-controller. The firmware handles the connection
to the driver, accepts new commands from the driver, controls the stepper
motor, and sends responses.

The same firmware is used when the driver is in simulation mode. The simulated
firmware handles the virtual "software-only" connection to the driver,
accepts new commands from the driver, controls a simulated stepper motor,
and sends responses.

Having simulated hardware that's a close match to the actual hardware is useful
for testing. The unit tests create an INDI Beefocus driver using a simulated
focuser, feed the driver commands (i.e. move to an absolute position), and
check the driver's output to make sure it's correct. The tests run in
"accelerated time"; a test sequence that would take minutes on an actual
focuser takes seconds on the simulated focuser.

To try out the simulator to to the Focuser's Connection menu, select
Simulated Connection instead of TCP Connect, and then press Connect in
Main Control.

INDI Driver Directory Layout
============================

File | Description
---- | -----------
driver/beefocus | The core INDI driver
driver/beeconnect | Connection interface to actual or simulated focuser
driver/beesimfirmware | Uses the Firmware to simulate the focuser
unit_tests/test_helpers | General Utilities for unit testing INDI drivers
unit_tests/test_driver | Beefocus unit tests (using the simulated firmware)
firmware/* | ESP8266 Firmware. Also used for simulation.

0 comments on commit 02d3964

Please sign in to comment.