Hi,
I don't think my Pi is getting images from the simulator.
The sim logs some warnings at start-up, but appears to function otherwise. SimulationFull.py seems to launch on my Pi ok, also with warnings. Output pasted below.
In more detail...
The sim shows the Borg's LED turn green (I assume that's what that dot on the large plan view of the Borg is) when I launch the script on my Pi. And the script on my Pi outputs frame rates until I press the sim's Stop button in the 'Video Streaming Settings' pane. So there's reason to believe the communication link has been established. (I added my host's IP address to a Sim/Pi file somewhere.)
When I execute the starting sequence in the sim, the AI bots start moving, but there is no rendering of the starting lights changing color in the sim (should there be?), and no response to the Red/Green button presses at all on my Pi. I tried setting ProcessImage.writeRawImages to True on my Pi, but no image files are generated in the script or log dir on my Pi. I've tried setting the sim to produce both .png and .jpg. During all of this, in the Bot Simulation pane of the sim, the Start button has been depressed; I've also tried cycling through the Stop and Reset buttons in various combinations.
I haven't touched any of the motor settings in the sim. I've left the Sims resolution settings at default 160x120. I did try checking the Flip Bot button with no luck.
The sim is running on a 2010 iMac / El Capitan 10.11.6. My Pi is a new RasPi 3 B+, configured per your instructions, using a 32GB USB drive rather than an SD card. The iMac is on WiFi; the Pi on ethernet. I'm interacting w/ the Pi via SSH.
Short of me diving in to the Pi script and adding a lot of debug statements, any idea what could be going wrong?
Thanks!
=============================================================================
Sim output:
01:20:28 Tue Oct 09 38 ~/work/pi/git/formulapi-code/Simulation$ java -jar Sim.jar
Screen: [2560x1440]
Loading File: [file:///Users/rene/work/pi/git/formulapi-code/Simulation/tracks/final.trk]
Start [1] : [550.0,60.0]
Start [2] : [550.0,90.0]
Start [3] : [550.0,120.0]
Start [4] : [550.0,150.0]
Start [5] : [550.0,180.0]
Bot Settings:
tyre_diameter : 10.2
bount_length : 19
motor_ref_rpm : 370
body_width : 50
bound_width : 18
motor_ref_volt : 12
tyre_width : 3.4
motor_accel : 0.10
motor_max_volt : 13.5
motor_decel : -0.10
Bot Settings:
tyre_diameter : 10.2
bount_length : 19
motor_ref_rpm : 370
body_width : 50
bound_width : 18
motor_ref_volt : 12
tyre_width : 3.4
motor_accel : 0.10
motor_max_volt : 13.5
motor_decel : -0.10
Bot Settings:
tyre_diameter : 10.2
bount_length : 19
motor_ref_rpm : 370
body_width : 50
bound_width : 18
motor_ref_volt : 12
tyre_width : 3.4
motor_accel : 0.10
motor_max_volt : 13.5
motor_decel : -0.10
Bot Settings:
tyre_diameter : 10.2
bount_length : 19
motor_ref_rpm : 370
body_width : 50
bound_width : 18
motor_ref_volt : 12
tyre_width : 3.4
motor_accel : 0.10
motor_max_volt : 13.5
motor_decel : -0.10
Bot Settings:
tyre_diameter : 10.2
bount_length : 19
motor_ref_rpm : 370
body_width : 50
bound_width : 18
motor_ref_volt : 12
tyre_width : 3.4
motor_accel : 0.10
motor_max_volt : 13.5
motor_decel : -0.10
Bot Settings:
tyre_diameter : 10.2
bount_length : 19
motor_ref_rpm : 370
body_width : 50
bound_width : 18
motor_ref_volt : 12
tyre_width : 3.4
motor_accel : 0.10
motor_max_volt : 13.5
motor_decel : -0.10
Video Stream Settings:
port : 10000
res : 160x120
autostart : false
[4.199999809265137,0.0]
[3.99443718704001,1.297871317434465]
[3.3978712220670335,2.4686979475172475]
[2.4686979475172475,3.3978712220670335]
[1.2978713174344652,3.99443718704001]
[2.571758161418022E-16,4.199999809265137]
[-1.2978713174344647,3.9944371870400106]
[-2.468697947517247,3.3978712220670335]
[-3.397871222067033,2.468697947517248]
[-3.99443718704001,1.2978713174344654]
[-4.199999809265137,5.143516322836044E-16]
[-3.99443718704001,-1.2978713174344663]
[-3.3978712220670335,-2.468697947517247]
[-2.468697947517248,-3.397871222067033]
[-1.2978713174344656,-3.99443718704001]
[-7.715274484254065E-16,-4.199999809265137]
[1.2978713174344643,-3.9944371870400106]
[2.4686979475172466,-3.397871222067034]
[3.397871222067033,-2.4686979475172484]
[3.99443718704001,-1.2978713174344658]
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: conn 0x1babf token 0x9ffffffffff899
Oct 9 23:08:48 java[53419] : Backtrace (at 2.30365e+06):
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 0 CoreGraphics 0x00007fff950d25ac CGSDisableUpdateToken + 155
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 1 AppKit 0x00007fff80e42420 ___disable_updates_sync_block_invoke_2 + 17
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 2 libdispatch.dylib 0x00007fff8f6c040b _dispatch_client_callout + 8
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 3 libdispatch.dylib 0x00007fff8f6c19f2 _dispatch_barrier_sync_f_invoke + 74
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 4 AppKit 0x00007fff80e422ee NSCGSDisableUpdates + 213
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 5 AppKit 0x00007fff80e42124 NSCGSTransactionRunPreCommitActionsForOrder_ + 156
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 6 AppKit 0x00007fff80e4206b NSCGSTransactionRunPreCommitActions_ + 21
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 7 AppKit 0x00007fff815f0ce4 -[_NSCGSTransaction synchronize] + 33
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 8 AppKit 0x00007fff815f0f59 NSCGSTransactionSynchronize + 76
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 9 AppKit 0x00007fff813dbfc5 -[NSSurface syncSurfaceWantsExtendedDynamicRange] + 150
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 10 AppKit 0x00007fff80f142cd -[NSSurface _createSurface] + 677
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 11 AppKit 0x00007fff80f13c28 -[NSSurface setFrame:] + 785
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 12 AppKit 0x00007fff813dc0cb __38-[NSSurface syncToViewUnconditionally]_block_invoke + 154
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 13 AppKit 0x00007fff80e31325 NSPerformVisuallyAtomicChange + 147
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 14 AppKit 0x00007fff80f1354c -[NSSurface syncToViewUnconditionally] + 100
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 15 AppKit 0x00007fff813dc164 __37-[NSSurface orderSurface:relativeTo:]_block_invoke + 44
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 16 AppKit 0x00007fff80e31325 NSPerformVisuallyAtomicChange + 147
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 17 AppKit 0x00007fff80f1341f -[NSSurface orderSurface:relativeTo:] + 160
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 18 AppKit 0x00007fff81006e56 NSOpenGLContextAttachOnScreenViewSurface + 183
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 19 AppKit 0x00007fff813336c7 __27-[NSOpenGLContext setView:]_block_invoke + 192
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 20 AppKit 0x00007fff80e31325 NSPerformVisuallyAtomicChange + 147
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 21 AppKit 0x00007fff80ff3c0d -[NSOpenGLContext setView:] + 119
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 22 libjogl_desktop.jnilib 0x000000012b4cbdc0 createContext + 400
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 23 libjogl_desktop.jnilib 0x000000012b531ab5 Java_jogamp_opengl_macosx_cgl_CGL_createContext0__JJZJZLjava_lang_Object_2I + 149
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 24 ??? 0x00000001105b7834 0x0 + 4569397300
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 25 ??? 0x00000001105a9dd0 0x0 + 4569341392
Oct 9 23:08:48 java[53419] : void CGSUpdateManager::log() const: 26 ??? 0x00000001105a9dd0 0x0 + 4569341392
Starting Server
After Bind
Shutting down server
Starting Server
After Bind
Shutting down server
Starting Server
After Bind
Shutting down server
Starting Server
After Bind
=====================================================================================
Pi output:
pi@tart:~/formulapi $ ./SimulationFull.py
Libraries loaded
Running script in directory "."
Error reading team colour
Colour: 1.00, 1.00, 1.00
>>> LED: 1.0 1.0 1.0
Image processor and Race Code Functions loaded
=== NEW SETTINGS ===
[Image setup]
Camera 160 x 120 at 30 fps
X cropped from 0 to 160
Y cropped from 60 to 120
Image processing threads: 4
[Startup]
Initial mode: 1
[Y scan lines]
60 (0)
63 (3)
66 (6)
69 (9)
72 (12)
75 (15)
78 (18)
81 (21)
84 (24)
87 (27)
90 (30)
93 (33)
96 (36)
99 (39)
102 (42)
105 (45)
108 (48)
111 (51)
114 (54)
117 (57)
[Colour identification]
Black limit: 90 100 50
Green gain: 1.10
Blue gain: 1.45
Target level for auto-gain: 200
Erosion factor for colour channels: 2
Final colour minimums: 1 1 1
[Line correction]
Colour edge gap: 32 pixels
Lane gap: 100 pixels
Offset Y calculation target 0: (15)
Corrective gain for derivative: 4.600
[Start marker detection]
Levels: Min Red = 45, Max Green = 60, Max Blue = 60
Start minimum match ratio: 90.0 %
Start crossed delay 0.10 s (3 frames)
Start re-detection delay: 10.0 s
Start detection zone X limits: 64 to 96
Start detection zone Y position: 40
[PID values]
P0: 0.100000 I0:0.000000 D0: 0.100000
P1: 0.055000 I1:0.000000 D1: 0.055000
P2: 0.000000 I2:0.000000 D2: 0.000000
[FIR filter]
Taps: 3
[Drive settings]
Maximum output: 100.0 %
Steering -200.0 % to +200.0 % (central +0.0 %)
Missing frames before stopping: 15
[Override settings]
Stuck detection threshold: 2.00
Stuck detection time: 1.00 s (30 frames)
Stuck reversing time: 0.70 s (21 frames)
Stuck hunting time: 0.40 s (12 frames)
Stuck colour detection at 80 x 48
Wrong way detection threshold: 10
Wrong way spin time: 0.80 s (24 frames)
Robot in front detection threshold: 36
Overtaking lane shift: 1.00
Overtaking time: 3.00 s (90 frames)
====================
Setup stream processor threads
06:45:07.979109 Processor thread 1 started with idle time of 0.27s
06:45:07.981055 Processor thread 2 started with idle time of 0.27s
06:45:07.983040 Processor thread 3 started with idle time of 0.27s
06:45:07.984927 Processor thread 4 started with idle time of 0.27s
Setup control loop
06:45:07.994366 Control loop thread started with idle time of 0.07s
Start Race.py
Start simulation capture thread
Press CTRL+C to quit
./SimulationFull.py:253: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
if frame == None:
/home/pi/formulapi/ImageProcessor.py:800: RuntimeWarning: divide by zero encountered in divide
adjustment = 255.0 / maximum
/home/pi/formulapi/ImageProcessor.py:874: RuntimeWarning: divide by zero encountered in divide
autoGainR = Settings.targetLevel / rAll.max()
/home/pi/formulapi/ImageProcessor.py:875: RuntimeWarning: divide by zero encountered in divide
autoGainG = Settings.targetLevel / gAll.max()
/home/pi/formulapi/ImageProcessor.py:876: RuntimeWarning: divide by zero encountered in divide
autoGainB = Settings.targetLevel / bAll.max()
/home/pi/formulapi/ImageProcessor.py:878: RuntimeWarning: invalid value encountered in multiply
red = (red - dropR) * Settings.redGain * autoGainR
/home/pi/formulapi/ImageProcessor.py:879: RuntimeWarning: invalid value encountered in multiply
green = (green - dropG) * Settings.greenGain * autoGainG
/home/pi/formulapi/ImageProcessor.py:880: RuntimeWarning: invalid value encountered in multiply
blue = (blue - dropB) * Settings.blueGain * autoGainB
06:45:08.740411 StartDetailedLoging()
06:45:08.761592 StartUserLog()
06:45:08.820222 WaitForGo()
27.3 FPS
30.9 FPS
29.2 FPS
31.0 FPS
30.5 FPS
30.5 FPS
30.0 FPS
29.7 FPS
30.4 FPS
30.1 FPS
31.5 FPS
30.2 FPS
29.4 FPS
30.7 FPS
30.3 FPS
30.7 FPS
30.6 FPS
29.2 FPS
30.5 FPS
30.3 FPS
30.7 FPS
29.6 FPS
30.5 FPS
30.4 FPS
30.7 FPS
29.4 FPS
30.6 FPS
30.4 FPS
Terminated
It looks like the simulator itself is not running correctly.
When you set the lights to green you should see them turn green in the small image in the top left of the simulator like this:
We have had very mixed results with people trying to run the simulator on OSX. Given the error message output I think it is likely the graphics card or driver does not support a function used by the simulator to render the camera image,
I know topshed managed to get the simulator running on a Windows virtual machine on his Mac using VMware Fusion (see here).
No, I don't see the lights in the sim. Thanks for the tip!
I use OS X and to get the robot to start in the Simulator replace WAIT_FOR_LIGHTS with FIRST_STRAIGHT in the file RaceCodeFunctions.py on line 38
VERY IMPORTANT to put it back for the race though - otherwise you will jump the lights :)
So ironic bit, I actually did develop the simulator on a (non-retina) macbook air running snow leopard, I'm due for an upgade to to new OSX, so I'll try it again on there after.
Arron has a really good point- if the lights aren't visible it won't draw it (call it a bug) since its mirroring the screen into the fake video feed. I had this problem because i was using the tiny 11" laptop
You should be able to go to in a browser on the machine to http://localhost:10000 and see what the robot would be seeing. I've included a sample of that. You can quickly check if its sending the entire image.
Add new comment