-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
thomas
committed
Oct 22, 2021
0 parents
commit 6038d37
Showing
1,906 changed files
with
21,270 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
__pycache__ | ||
/app/bin/content | ||
*.fbm | ||
/resources_compiled | ||
/app/resources_compiled |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Python: Poppy api rest", | ||
"type": "python", | ||
"request": "launch", | ||
"program": "poppy_api_rest.py", | ||
"cwd": "${workspaceFolder}/app", | ||
"console": "integratedTerminal" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# HARFANG® 3.0 Poppy Ergo Jr | ||
|
||
This project demonstrate the usage of the [HARFANG 3.0 API](https://www.harfang3d.com/releases/3.0.0/) in **Python** with the [**Poppy Ergo Junior**](https://www.poppy-project.org/en/robots/poppy-ergo-jr/) robot. | ||
|
||
[![](https://raw.githubusercontent.com/harfang3d/image-storage/main/portfolio/3.0.0/digital-twin-poppy-ergo-jr-yt.png)](https://www.youtube.com/watch?v=5kzy_JD_1Ag) | ||
|
||
## To run the project: | ||
|
||
### Windows (Win64) platform: | ||
|
||
```bash | ||
git clone https://github.com/harfang3d/python-digital-twin poppy | ||
cd poppy/ | ||
curl https://www.harfang3d.com/releases/3.0.0/assetc-win-x64-3.0.0.zip --output assetc.zip | ||
powershell -command "Expand-Archive assetc.zip assetc" | ||
pip install -r requirements.txt | ||
assetc\assetc.exe resources app/resources_compiled | ||
cd app | ||
python poppy_api_rest.py | ||
``` | ||
|
||
### Linux platform: | ||
|
||
```bash | ||
git clone https://github.com/harfang3d/python-digital-twin poppy | ||
cd poppy/ | ||
wget https://www.harfang3d.com/releases/3.0.0/assetc-ubuntu-x64-3.0.0.zip | ||
unzip assetc-ubuntu-x64-3.0.0.zip -d assetc | ||
wget https://www.harfang3d.com/releases/3.0.0/harfang-3.0.0-cp32-abi3-linux_x86_64.whl | ||
python3 -m pip install harfang-3.0.0-cp32-abi3-linux_x86_64.whl | ||
assetc/assetc resources app/resources_compiled | ||
cd app | ||
python3 poppy_api_rest.py | ||
``` | ||
|
||
## Notes: | ||
|
||
* To run the program, you can also open the project folder using [Visual Studio Code](https://code.visualstudio.com/) and use the provided debug target. | ||
* If you want to know more about HARFANG, please visit the [official website](https://www.harfang3d.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import harfang as hg | ||
|
||
d = 5 | ||
|
||
cam_rot_speed = 0.5 | ||
k_wheel = 10 | ||
|
||
|
||
def OrbitalController(keyboard, mouse, cam_pos, cam_rot, cam_tgt, dt, width, height): | ||
global d | ||
dt_sec = hg.time_to_sec_f(dt) | ||
|
||
k_ar = hg.ComputeAspectRatioX(width, height).x | ||
|
||
state_modified = False | ||
if mouse.Down(hg.MB_0): | ||
speed = dt_sec * cam_rot_speed | ||
delta_x = mouse.DtX() | ||
delta_y = -mouse.DtY() | ||
cam_rot.x += delta_y * speed | ||
cam_rot.y += delta_x * speed | ||
|
||
# clamp X | ||
if cam_rot.x > 1.57: | ||
cam_rot.x = 1.57 | ||
if cam_rot.x < 0: | ||
cam_rot.x = 0 | ||
|
||
if keyboard.Down(hg.K_LAlt): | ||
if mouse.Down(hg.MB_0): | ||
z_value = -mouse.DtY() * 5 | ||
speed = d * dt_sec * 10 | ||
d += z_value * speed | ||
|
||
if mouse.Wheel() != 0: | ||
wheel_dt = mouse.Wheel() | ||
|
||
k = abs(wheel_dt) * k_wheel * dt_sec | ||
if wheel_dt > 0: | ||
d /= k + 1 | ||
else: | ||
d *= k + 1 | ||
|
||
if d < 3: | ||
d = 3 # make sure not to come too close to the target | ||
if d > 28: | ||
d = 28 | ||
|
||
if mouse.Down(hg.MB_2): # scroll viewpoint | ||
speed = d * dt_sec * 0.1 | ||
mat = hg.TransformationMat4(cam_pos, cam_rot) | ||
cam_tgt += (hg.GetX(mat) * -mouse.DtX() * k_ar + hg.GetY(mat) * -mouse.DtY()) * speed | ||
|
||
world = hg.TransformationMat4(cam_tgt, cam_rot, hg.Vec3.One) * hg.TranslationMat4(hg.Vec3(0, 0, -d)) | ||
return world, cam_rot, cam_tgt, hg.GetT(world) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
..\assetc\assetc.exe ..\resources resources_compiled |
Binary file not shown.
Oops, something went wrong.