Teensy interface: Difference between revisions

From Rsewiki
No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 3: Line 3:
=== Installation packages ===
=== Installation packages ===


See installation notes for needed OS-packages.
See installation notes for needed OS-packages: [[Scorpi Pi installation]].


=== Teensy interface source ===
=== Teensy interface source ===
Line 107: Line 107:
=== Configuration in Robot.ini ===
=== Configuration in Robot.ini ===


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


[service]
[service]
use_robot_hardware = true
use_robot_hardware = true
logpath = log_%d/
logpath = log_%d/
; the '%d' will be replaced with date and timestamp (must end with a '/'). =  
; the '%d' will be replaced with date and timestamp (must end with a '/'). =  
 
[teensy0]
[teensy0]
use = true
use = true
type = robobot
type = robobot
idx = 93
idx = 93
; robot 'name' and 'idx' are read-only, use command line option to change =  
; robot 'name' and 'idx' are read-only, use command line option to change =  
name = Rumle
name = Rumle
device = /dev/ttyACM0
device = /dev/ttyACM0
log = true
log = true
print = false
print = false
confirm_timeout = 0.04
confirm_timeout = 0.04
encrev = true
encrev = true
hardware = 10
hardware = 10
 
[state0]
[state]
log = true
log = true
print = false
print = false
regbot_version = 1646
regbot_version = 1646
shutdown_file = shutdown.now
shutdown_file = shutdown.now
 
[encoder0]
[encoder0]
rate_ms = 8
rate_ms = 8
log = true
log = true
print = false
print = false
encoder_reversed = true
encoder_reversed = true
 
[imu1teensy0]
[imu1teensy0]
rate_ms = 12
rate_ms = 12
gyro_offset = 0 0 0
gyro_offset = 0 0 0
log = true
log = true
print_gyro = false
print_gyro = false
print_acc = false
print_acc = false
 
[imu2teensy0]
[imu2teensy0]
rate_ms = 12
rate_ms = 12
gyro_offset = 0 0 0
gyro_offset = 0 0 0
log = true
log = true
print_gyro = false
print_gyro = false
print_acc = false
print_acc = false  
 
[servotn0]
[servotn0]
rate_ms = 50
rate_ms = 50
log = true
log = true
print = true
print = true  
 
[teensy1]
[teensy1]
use = false
use = false
type = robobot
type = robobot
idx = 2
idx = 2
; robot 'name' and 'idx' are read-only, use command line option to change =  
; robot 'name' and 'idx' are read-only, use command line option to change =  
name = noname
name = noname
device = /dev/ttyACM1
device = /dev/ttyACM1
log = true
log = true
print = false
print = false
confirm_timeout = 0.04
confirm_timeout = 0.04
encrev = true
encrev = true
 
[state1]
[state1]
log = true
log = true
print = false
print = false
regbot_version = 000
regbot_version = 000  
 
[encoder1]
[encoder1]
rate_ms = 8
rate_ms = 8
log = true
log = true
print = false
print = false
encoder_reversed = true
encoder_reversed = true  
 
[imu1teensy1]
[imu1teensy1]
rate_ms = 12
rate_ms = 12
gyro_offset = 0 0 0
gyro_offset = 0 0 0
log = true
log = true
print_gyro = false
print_gyro = false
print_acc = false
print_acc = false
 
[imu2teensy1]
[imu2teensy1]
rate_ms = 12
rate_ms = 12
gyro_offset = 0 0 0
gyro_offset = 0 0 0
log = true
log = true
print_gyro = false
print_gyro = false
print_acc = false
print_acc = false
 
[servotn1]
[servotn1]
rate_ms = 50
rate_ms = 50
log = true
log = true
print = true
print = true
 
[pose]
[pose]
gear = 19.0
gear = 19.0
wheeldiameter = 0.146
wheeldiameter = 0.146
enctickperrev = 68
enctickperrev = 68
wheelbase = 0.243
wheelbase = 0.243
log = true
log = true
print = false
print = false
 
[gpio]
[gpio]
pins_out = 12=0 16=0
pins_out = 12=0 16=0
stop_on_stop = true
stop_on_stop = true
blink_period_ms = 600
blink_period_ms = 600
log = true
log = true
print = false
print = false
 
[mixer]
[mixer]
log = true
log = true
print = false
print = false
 
[heading]
[heading]
kp = 10.0
kp = 10.0
lead = 0.0 1.0
lead = 0.0 1.0
taui = 0.0
taui = 0.0
maxturnrate = 3.0
maxturnrate = 3.0
log = true
log = true
print = false
print = false
 
[pyvision]
[pyvision]
host = localhost
host = localhost
port = 25001
port = 25001
log = true
log = true
print = false
print = false
enabled = false
enabled = false
 
[joy_logitech]
[joy_logitech]
log = true
log = true
print = false
print = false
device = /dev/input/js0
device = /dev/input/js0
limit = 1.5 1.5 0.1
limit = 1.5 1.5 0.1
button_fast = 5
button_fast = 5
axis_vel = 4
axis_vel = 4
axis_turn = 3
axis_turn = 3
slow_factor = 0.3
slow_factor = 0.3
axis_servo = 1
axis_servo = 1
servo = 1
servo = 1
log_all = true
log_all = true
device_type = Logitech Gamepad F710
device_type = Logitech Gamepad F710
 
[camera]
[camera]
device = 0
device = 0
width = 1280
width = 1280
height = 720
height = 720
fps = 25
fps = 25
matrix = 1000 0 640 0 1000 360 0 0 1
matrix = 1000 0 640 0 1000 360 0 0 1
distortion = -0.415 0.2244 -6.875e-5 0.001279 -0.073412
distortion = -0.415 0.2244 -6.875e-5 0.001279 -0.073412
imagepath = img
imagepath = img
imagename = %d
imagename = %d
log = true
log = true
print = false
print = false
enabled = false
enabled = false
pos = 0.11 0 0.23
pos = 0.11 0 0.23
cam_tilt = 0.01
cam_tilt = 0.01
 
[aruco]
[aruco]
imagepath = aruco
imagepath = aruco
save = true
save = true
log = true
log = true
print = true
print = true
 
[ini]
[in]
; set 'saveconfig' to 'false' to avoid autosave =  
; set 'saveconfig' to 'false' to avoid autosave =  
saveconfig = true
saveconfig = true
version = 11 2024-04-22 14:40:34
version = 11 2024-04-22 14:40:34
 
[plan100]
[plan100]
log = true
log = true
run = true
run = true
print = true
print = true
 
[as5147u_0]
[as5147u_0]
rate_pos_ms = 8
rate_pos_ms = 8
rate_vel_ms = 81
rate_vel_ms = 81
rate_err_ms = 82
rate_err_ms = 82
logpos = true
logpos = true
logvel = true
logvel = true
logerr = true
logerr = true
print = false
print = false
 
[as5147u_1]
[as5147u_1]
rate_pos_ms = 8
rate_pos_ms = 8
rate_vel_ms = 81
rate_vel_ms = 81
rate_err_ms = 82
rate_err_ms = 82
logpos = true
logpos = true
logvel = true
logvel = true
logerr = true
logerr = true
print = false
print = false
 
 
[motor_teensy_0]
[motor_teensy_0]
kp = 7.0
kp = 7.0
lead = 0 1.0
lead = 0 1.0
taui = 0.05
taui = 0.05
maxmotv = 10.0
maxmotv = 10.0
log_pid_m1 = false
log_pid_m1 = false
log_pid_m2 = false
log_pid_m2 = false
log_pid_m3 = false
log_pid_m3 = false
log_pid_m4 = false
log_pid_m4 = false
log_voltage = true
log_voltage = true
print_m1 = false
print_m1 = false
print_m2 = false
print_m2 = false
print_m3 = false
print_m3 = false
print_m4 = false
print_m4 = false
motv_sample_time = 33
motv_sample_time = 33
motpwm_sample_time = 33
motpwm_sample_time = 33
 
[motor_teensy_1]
[motor_teensy_1]
kp = 7.0
kp = 7.0
lead = 0 1.0
lead = 0 1.0
taui = 0.05
taui = 0.05
maxmotv = 10.0
maxmotv = 10.0
log_pid_m1 = false
log_pid_m1 = false
log_pid_m2 = false
log_pid_m2 = false
log_pid_m3 = false
log_pid_m3 = false
log_pid_m4 = false
log_pid_m4 = false
log_voltage = true
log_voltage = true
print_m1 = false
print_m1 = false
print_m2 = false
print_m2 = false
print_m3 = false
print_m3 = false
print_m4 = false
print_m4 = false
motv_sample_time = 33
motv_sample_time = 33
motpwm_sample_time =
motpwm_sample_time =

Latest revision as of 12:28, 21 July 2024

Back to Scorpi

Installation packages

See installation notes for needed OS-packages: Scorpi Pi installation.

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 are probably added or removed 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

[state]
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

[in]
; 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 =