Teensy interface

From Rsewiki
Revision as of 12:14, 21 July 2024 by Jca (talk | contribs)

Back to Scorpi

Installation packages

See installation notes for needed OS-packages.

Teensy interface source

For the Teensy interface fetch the software here:

mkdir -p ~/svn
cd ~/svn
svn checkout svn://repos.gbar.dtu.dk/jcan/scorpi

Teensy_interface - CMake

Then go to the Teensy_interface and compile like this:

cd scorpi/teensy_interface
mkdir build
cd build
cmake ..

-- The C compiler identification is GNU 10.2.1
-- The CXX compiler identification is GNU 10.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found OpenCV: /usr (found version "4.5.1") 
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in thread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
# Is a RASPBERRY; CPU=aarch64 (Pi3=armv7l, pi4=aarch64)
-- Configuring done
-- Generating done
-- Build files have been written to: /home/local/svn/scorpi/teensy_interface/build

A Makefile is now generated.

Compile Teensy_interface

To compile:

cd ~/svn/scorpi/teensy_interface/build
make -j3

local@joe:~/svn/scorpi/teensy_interface/build $ make -j3
Scanning dependencies of target teensy_interface
[  9%] Building CXX object CMakeFiles/teensy_interface.dir/src/cheading.cpp.o
[  9%] Building CXX object CMakeFiles/teensy_interface.dir/src/bplan100.cpp.o
[ 13%] Building CXX object CMakeFiles/teensy_interface.dir/src/cmixer.cpp.o
[ 18%] Building CXX object CMakeFiles/teensy_interface.dir/src/cmotor.cpp.o
[ 22%] Building CXX object CMakeFiles/teensy_interface.dir/src/cservo.cpp.o
[ 27%] Building CXX object CMakeFiles/teensy_interface.dir/src/main.cpp.o
[ 31%] Building CXX object CMakeFiles/teensy_interface.dir/src/maruco.cpp.o
[ 36%] Building CXX object CMakeFiles/teensy_interface.dir/src/mpose.cpp.o
[ 40%] Building CXX object CMakeFiles/teensy_interface.dir/src/sas5147u.cpp.o
[ 45%] Building CXX object CMakeFiles/teensy_interface.dir/src/scam.cpp.o
[ 50%] Building CXX object CMakeFiles/teensy_interface.dir/src/sencoder.cpp.o
[ 54%] Building CXX object CMakeFiles/teensy_interface.dir/src/sgpiod.cpp.o
[ 59%] Building CXX object CMakeFiles/teensy_interface.dir/src/simu.cpp.o
[ 63%] Building CXX object CMakeFiles/teensy_interface.dir/src/sjoylogitech.cpp.o
[ 68%] Building CXX object CMakeFiles/teensy_interface.dir/src/spyvision.cpp.o
[ 72%] Building CXX object CMakeFiles/teensy_interface.dir/src/sstate.cpp.o
[ 77%] Building CXX object CMakeFiles/teensy_interface.dir/src/steensy.cpp.o
[ 81%] Building CXX object CMakeFiles/teensy_interface.dir/src/upid.cpp.o
[ 86%] Building CXX object CMakeFiles/teensy_interface.dir/src/uservice.cpp.o
/home/local/svn/scorpi/teensy_interface/src/steensy.cpp: In member function ‘bool UOutQueue::setMessage(const char*)’:
/home/local/svn/scorpi/teensy_interface/src/steensy.cpp:66:12: warning: ‘char* strncpy(char*, const char*, size_t)’ output may be  truncated copying 3 bytes from a string of length 3 [-Wstringop-truncation]
   66 |     strncpy(msg, cc, 3);
      |     13:06, 21 July 2024 (CEST)~~^13:06, 21 July 2024 (CEST)13:06, 21 July 2024 (CEST)~
[ 90%] Building CXX object CMakeFiles/teensy_interface.dir/src/usocket.cpp.o
[ 95%] Building CXX object CMakeFiles/teensy_interface.dir/src/utime.cpp.o
[100%] Linking CXX executable teensy_interface
[100%] Built target teensy_interface

After a while, all should be compiled with a few warnings. Test if it can run:

Test the compiled Teensy_interface

local@joe:~/svn/scorpi/teensy_interface/build $ ./teensy_interface 
# UService:: created directory log_20240721_130326.804/
# UService::setup: open to Teensy 0
# UService::setup: open to Teensy 1
# SGpiod::setup there is no GPIO chip found - disable function
# SpyVision:: disabled in robot.ini
# UCam:: disabled in robot.ini
# --------- terminating -----------
# UService:: configuration saved to robot.ini

Output depends on the configuration file "robot.ini" created with default values.

Configuration in Robot.ini

This file could look something like this (other options is probably added since this dump):

[service] use_robot_hardware = true logpath = log_%d/

the '%d' will be replaced with date and timestamp (must end with a '/'). =

[teensy0] use = true type = robobot idx = 93

robot 'name' and 'idx' are read-only, use command line option to change =

name = Rumle device = /dev/ttyACM0 log = true print = false confirm_timeout = 0.04 encrev = true hardware = 10

[state0] log = true print = false regbot_version = 1646 shutdown_file = shutdown.now

[encoder0] rate_ms = 8 log = true print = false encoder_reversed = true

[imu1teensy0] rate_ms = 12 gyro_offset = 0 0 0 log = true print_gyro = false print_acc = false

[imu2teensy0] rate_ms = 12 gyro_offset = 0 0 0 log = true print_gyro = false print_acc = false

[servotn0] rate_ms = 50 log = true print = true

[teensy1] use = false type = robobot idx = 2

robot 'name' and 'idx' are read-only, use command line option to change =

name = noname device = /dev/ttyACM1 log = true print = false confirm_timeout = 0.04 encrev = true

[state1] log = true print = false regbot_version = 000

[encoder1] rate_ms = 8 log = true print = false encoder_reversed = true

[imu1teensy1] rate_ms = 12 gyro_offset = 0 0 0 log = true print_gyro = false print_acc = false

[imu2teensy1] rate_ms = 12 gyro_offset = 0 0 0 log = true print_gyro = false print_acc = false

[servotn1] rate_ms = 50 log = true print = true

[pose] gear = 19.0 wheeldiameter = 0.146 enctickperrev = 68 wheelbase = 0.243 log = true print = false

[gpio] pins_out = 12=0 16=0 stop_on_stop = true blink_period_ms = 600 log = true print = false

[mixer] log = true print = false

[heading] kp = 10.0 lead = 0.0 1.0 taui = 0.0 maxturnrate = 3.0 log = true print = false

[pyvision] host = localhost port = 25001 log = true print = false enabled = false

[joy_logitech] log = true print = false device = /dev/input/js0 limit = 1.5 1.5 0.1 button_fast = 5 axis_vel = 4 axis_turn = 3 slow_factor = 0.3 axis_servo = 1 servo = 1 log_all = true device_type = Logitech Gamepad F710

[camera] device = 0 width = 1280 height = 720 fps = 25 matrix = 1000 0 640 0 1000 360 0 0 1 distortion = -0.415 0.2244 -6.875e-5 0.001279 -0.073412 imagepath = img imagename = %d log = true print = false enabled = false pos = 0.11 0 0.23 cam_tilt = 0.01

[aruco] imagepath = aruco save = true log = true print = true

[ini]

set 'saveconfig' to 'false' to avoid autosave =

saveconfig = true version = 11 2024-04-22 14:40:34

[plan100] log = true run = true print = true

[as5147u_0] rate_pos_ms = 8 rate_vel_ms = 81 rate_err_ms = 82 logpos = true logvel = true logerr = true print = false

[as5147u_1] rate_pos_ms = 8 rate_vel_ms = 81 rate_err_ms = 82 logpos = true logvel = true logerr = true print = false


[motor_teensy_0] kp = 7.0 lead = 0 1.0 taui = 0.05 maxmotv = 10.0 log_pid_m1 = false log_pid_m2 = false log_pid_m3 = false log_pid_m4 = false log_voltage = true print_m1 = false print_m2 = false print_m3 = false print_m4 = false motv_sample_time = 33 motpwm_sample_time = 33

[motor_teensy_1] kp = 7.0 lead = 0 1.0 taui = 0.05 maxmotv = 10.0 log_pid_m1 = false log_pid_m2 = false log_pid_m3 = false log_pid_m4 = false log_voltage = true print_m1 = false print_m2 = false print_m3 = false print_m4 = false motv_sample_time = 33 motpwm_sample_time =