Skip to content

Commit 1ee2f30

Browse files
committed
Fix CSP
1 parent 85bde65 commit 1ee2f30

File tree

3 files changed

+911
-10
lines changed

3 files changed

+911
-10
lines changed

electron_demo/turtle_tf2/README.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,35 +85,54 @@ The demo uses the following key dependencies:
8585
This step is crucial for ensuring that rclnodejs and other native dependencies are properly compiled for your system.
8686

8787
4. **Source ROS2 environment**:
88+
8889
```bash
8990
source /opt/ros/$ROS_DISTRO/setup.bash
9091
```
9192

93+
**Important**: The ROS2 environment must be sourced in the same terminal session where you run `npm start`.
94+
9295
## Running the Demo
9396

97+
**⚠️ Important Setup Note**: Before running the demo, make sure to:
98+
99+
1. Source the ROS2 environment in your terminal: `source /opt/ros/$ROS_DISTRO/setup.bash`
100+
2. Keep this terminal session active for the entire demo run
101+
94102
### Method 1: Complete Demo
95103

96104
Start the full demo with all components (ensure you have run `npm install && npm run rebuild` first):
97105

98106
```bash
107+
# Source ROS2 first
108+
source /opt/ros/$ROS_DISTRO/setup.bash
109+
110+
# Then start the demo
99111
npm start
100112
```
101113

102114
### Method 2: Step-by-Step Launch
103115

104-
1. **Start turtlesim (in separate terminal)**:
116+
1. **Source ROS2 environment**:
105117

106118
```bash
119+
source /opt/ros/$ROS_DISTRO/setup.bash
120+
```
121+
122+
2. **Start turtlesim (in separate terminal, also sourced)**:
123+
124+
```bash
125+
source /opt/ros/$ROS_DISTRO/setup.bash
107126
ros2 run turtlesim turtlesim_node
108127
```
109128

110-
2. **Launch the Electron application**:
129+
3. **Launch the Electron application**:
111130

112131
```bash
113132
npm start
114133
```
115134

116-
3. **Use the web interface to**:
135+
4. **Use the web interface to**:
117136
- Click "Spawn Turtle1" to create the first turtle
118137
- Click "Spawn Turtle2" to create the second turtle
119138
- Click "Start Demo" to initialize all TF2 broadcasters
@@ -200,10 +219,12 @@ world → turtle2
200219

201220
### Common Issues
202221

203-
1. **"Cannot connect to ROS2"**
222+
1. **"Cannot connect to ROS2" or "librcl.so: cannot open shared object file"**
204223

205224
- Ensure ROS2 is sourced: `source /opt/ros/$ROS_DISTRO/setup.bash`
225+
- **Critical**: Source ROS2 in the SAME terminal where you run `npm start`
206226
- Check if ROS2 daemon is running: `ros2 daemon status`
227+
- Verify ROS2 installation: `ros2 --version`
207228

208229
2. **"Turtlesim not responding"**
209230

@@ -228,9 +249,15 @@ world → turtle2
228249
- Try deleting `node_modules` and running `npm install && npm run rebuild` again
229250

230251
6. **"THREE is not defined" or script loading errors**
231-
- The demo uses CDN versions of Three.js which require internet connection
232-
- If you see CSP (Content Security Policy) errors, ensure the CSP in index.html allows CDN domains
233-
- For offline use, you can install Three.js locally: `npm install [email protected]` and update script paths in index.html
252+
253+
- Ensure Three.js is properly installed: `npm install [email protected]`
254+
- Check that `node_modules/three/build/three.min.js` exists
255+
- If issues persist, try reinstalling: `rm -rf node_modules && npm install && npm run rebuild`
256+
257+
7. **WSL (Windows Subsystem for Linux) specific issues**
258+
- Install audio libraries: `sudo apt install libasound2t64 libasound2-dev`
259+
- Enable X11 forwarding for GUI: Install VcXsrv or similar X server
260+
- Some GUI features may be limited in WSL environment
234261

235262
### Debugging Commands
236263

electron_demo/turtle_tf2/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOC <meta http-equiv="Content-Security-Policy"
2-
content="default-src 'self'; script-src 'self' 'unsafe-inline' https://cdnjs.cloudflare.com https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline';">PE html>
2+
content="default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline';">PE html>
33
<html>
44

55
<head>
@@ -428,8 +428,8 @@ <h1>🐢 Turtle TF2 Transformation Demo</h1>
428428
</div>
429429

430430
<!-- Include Three.js -->
431-
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r155/three.min.js"></script>
432-
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.js"></script>
431+
<script src="./node_modules/three/build/three.min.js"></script>
432+
<script src="./orbit-controls.js"></script>
433433

434434
<!-- Main renderer script -->
435435
<script src="./renderer.js"></script>

0 commit comments

Comments
 (0)