Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connecting the digital twin to the real robot using ros and updating the readme file #4

Open
wants to merge 155 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
7b36b6a
add wheel collision model
samFabrice May 19, 2022
fb0e66e
Merge branch 'collision_model' of github.com:CRIStAL-PADR/prefab.Mobi…
samFabrice May 19, 2022
6265788
Add wheel collision model, add wheel collision file and remove unnece…
samFabrice May 19, 2022
48e0bba
WIP
samFabrice May 20, 2022
c0c61df
V1 echelon
AlessandriniAntoine May 20, 2022
629050b
Merge pull request #2 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice May 20, 2022
d9b34b9
WIP
samFabrice May 23, 2022
a53ba45
WIP
samFabrice May 23, 2022
b147749
real scale base
AlessandriniAntoine May 23, 2022
e5eb13d
Merge pull request #3 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice May 23, 2022
7385f52
WIP
samFabrice May 23, 2022
e351218
WIP
AlessandriniAntoine May 23, 2022
cd0a122
Merge branch 'coupling_trunk_and_summit_xl' of github.com:Alessandrin…
AlessandriniAntoine May 23, 2022
1d176d8
Merge pull request #4 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice May 23, 2022
63de912
Echelon function
AlessandriniAntoine May 23, 2022
67dbae0
Merge pull request #5 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice May 23, 2022
2fca450
Trunk connection V2 WIP
AlessandriniAntoine May 23, 2022
34c521f
Merge pull request #6 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice May 23, 2022
c45877c
WIP
samFabrice May 24, 2022
13266d6
Fixing trunk to the Chassis
samFabrice May 24, 2022
20bde39
WIP
samFabrice May 24, 2022
644fe30
NewConnection + mapping
AlessandriniAntoine May 25, 2022
b60e12b
Spring Correction V3
AlessandriniAntoine May 30, 2022
7766194
WIP
AlessandriniAntoine Jun 30, 2022
db85a49
I created an echelon3 folder where I put all the files relating to ec…
samFabrice Jun 30, 2022
19ca839
add collision
samFabrice Jun 30, 2022
575cecb
Remove unnecessary code
samFabrice Jul 1, 2022
8dee875
Remove unnecessary commented code and Commented the code that allows …
samFabrice Jul 1, 2022
0bae999
Fixed the teleop_key to be able to send commands to the simulation
samFabrice Jul 1, 2022
682ec85
Updated the ros_summitxl to fix a bug by increasing the alarmDistance…
samFabrice Jul 7, 2022
e461122
I uncommented the line that allowed me to calculate the dt of the sim…
samFabrice Jul 7, 2022
21df57f
minor cleaning
samFabrice Jul 7, 2022
6fbafcf
I made some corrections so that I could drive the real robot using th…
samFabrice Jul 11, 2022
5d6a231
Integration of the trunk into the ros model of the robot
samFabrice Jul 11, 2022
3dd8ac0
WIP
samFabrice Jul 12, 2022
9da8e10
WIP
samFabrice Jul 12, 2022
48c5438
WIP
samFabrice Jul 12, 2022
eb97217
WIP
samFabrice Jul 12, 2022
537bf08
WIP
samFabrice Jul 12, 2022
1d38a79
WIP
samFabrice Jul 12, 2022
4cf9ebc
WIP
samFabrice Jul 12, 2022
6e67199
Updated REDAME file
samFabrice Jul 12, 2022
02d4d32
Updated REDAME file
samFabrice Jul 12, 2022
6c15efd
Updated README file
samFabrice Jul 12, 2022
aebe9de
Updated REDAME file
samFabrice Jul 12, 2022
f5f71f1
conflict management on the main branch
samFabrice Jul 12, 2022
5836759
add test using ros api section
samFabrice Jul 12, 2022
32b100e
fixed sofa UI image rendering in test section
samFabrice Jul 12, 2022
7f05d89
WIP
samFabrice Jul 13, 2022
de2420b
WIP
samFabrice Jul 18, 2022
47c9711
WIP
samFabrice Jul 18, 2022
3ee1f4c
WIP
samFabrice Jul 18, 2022
58566e4
update
AlessandriniAntoine Jul 19, 2022
4e2c542
Merge pull request #7 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice Jul 19, 2022
c4defc5
couple controller
AlessandriniAntoine Jul 19, 2022
7465831
Merge branch 'coupling_trunk_and_summit_xl' of github.com:Alessandrin…
AlessandriniAntoine Jul 19, 2022
6dfce86
Merge pull request #8 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice Jul 19, 2022
221cb94
Merge remote-tracking branch 'refs/remotes/origin/coupling_trunk_and_…
samFabrice Jul 19, 2022
71eb229
WIP
samFabrice Jul 20, 2022
1540514
Add a visual model to the trunk
samFabrice Jul 25, 2022
ca8d958
WIP
samFabrice Jul 26, 2022
fb1ec02
removed the collision model on the wheels
samFabrice Jul 28, 2022
3603574
Readme.md
Jul 29, 2022
373e660
Merge pull request #9 from AlessandriniAntoine/coupling_trunk_and_sum…
samFabrice Aug 22, 2022
6976613
Updated the README
samFabrice Aug 22, 2022
b910e7a
Updated the README
samFabrice Aug 22, 2022
f929e3f
Updated the README
samFabrice Aug 24, 2022
69efdee
I created a Summit_xl_and_trunk file in order to have a scene to simu…
samFabrice Aug 24, 2022
561e389
resolving conflit
samFabrice Aug 24, 2022
353daa7
Updated working space
samFabrice Aug 24, 2022
a929cf3
WIP
samFabrice Aug 25, 2022
90a0e52
WIP
samFabrice Aug 25, 2022
67131eb
refactoring
samFabrice Aug 29, 2022
503a527
Changed summit_xl_trunk.py into scene.py
samFabrice Aug 29, 2022
95ad80d
minor refactoring and fixing the camera to the trunk
samFabrice Aug 29, 2022
dbf327b
Fixed Camera
samFabrice Aug 30, 2022
bad7bb2
Fixed summit_xl controller
samFabrice Sep 2, 2022
4e9e8c1
remove commented code
samFabrice Sep 2, 2022
0c63f7d
remove unnecessary print
samFabrice Sep 2, 2022
7fead95
wip
samFabrice Sep 2, 2022
49cd7a3
wip
samFabrice Sep 7, 2022
0fe3071
Add new texture files and update summit_xl.py file
samFabrice Oct 10, 2022
c5065cd
remove unnecessary texture folder
samFabrice Oct 13, 2022
51f2772
remove unnecessary files
samFabrice Oct 13, 2022
9f27b57
Fixing scene
samFabrice Oct 14, 2022
8786da1
Fix ros controller
samFabrice Oct 14, 2022
4c78fc0
Fix ros controller
samFabrice Oct 17, 2022
3ad5887
Minor refactoring
samFabrice Oct 17, 2022
0ee4fdb
Minor refactoring
samFabrice Oct 17, 2022
63b4322
WIP
samFabrice Oct 17, 2022
4ad390b
Fix ros controller
samFabrice Oct 17, 2022
4a1451a
WIP
samFabrice Oct 21, 2022
d39d3b5
WIP
samFabrice Oct 27, 2022
3f8b740
I created a file in which I calculate the angular speed of each whee…
samFabrice Oct 27, 2022
c84b4d8
remove unecessary print
samFabrice Oct 27, 2022
d778255
WIP
samFabrice Oct 27, 2022
0c26c84
Fix summit xl controllers
samFabrice Oct 28, 2022
77e42bb
removed unnecessary print
samFabrice Oct 28, 2022
29047c8
Add a scene for functionnal test
samFabrice Oct 28, 2022
231d78d
updated scene.py file
samFabrice Oct 28, 2022
d597f92
WIP
samFabrice Oct 31, 2022
1233d52
WIP
samFabrice Oct 31, 2022
f8c5737
WIP
samFabrice Oct 31, 2022
5b5795d
updated the README
samFabrice Oct 31, 2022
95c65a0
I commented the code that attached the trunk to the robot in order to…
samFabrice Nov 3, 2022
22f300f
Add a presentation of prefab.MoblieTrunkP
samFabrice Nov 10, 2022
107959a
adding scale parameter in floor object
samFabrice Dec 5, 2022
20f99ee
add comment on how to get wheel_ray lx, lz value
samFabrice Dec 8, 2022
c41e652
update scene.py file
samFabrice Dec 8, 2022
55b1583
WIP
samFabrice Dec 8, 2022
0e7bbf2
Correction of the implemented mathematical model (holonomic robot mod…
samFabrice Dec 19, 2022
c6bb8d3
remove unecessary robot param
samFabrice Dec 19, 2022
9e7a928
Add missing parameter in SIMTORobot ros sender
samFabrice Jan 3, 2023
2f179f5
Add the correct controller of the robot
samFabrice Jan 3, 2023
4229506
WIP
samFabrice Jan 3, 2023
9e94456
WIP
samFabrice Jan 4, 2023
1532ed6
WIP
samFabrice Jan 6, 2023
c46e366
Add note on digital twin test validation
samFabrice Jan 6, 2023
915e958
Update the README
samFabrice Jan 6, 2023
c293115
Add joint_state msg to acces to the wheels velocity
samFabrice Feb 21, 2023
3821334
I added variables allowing me to store the rotation speed of the 4 wh…
samFabrice Feb 28, 2023
fd4a981
Design of a ros interface for the trunk
samFabrice Mar 2, 2023
6b7ede6
Remove unecessary print
samFabrice Mar 2, 2023
65e65b2
WIP
samFabrice Mar 2, 2023
a3e5010
Add ROScontroller interface to the echelon3
samFabrice Mar 2, 2023
8ddcafc
Update Echelon3 Ros interface
samFabrice Mar 3, 2023
ba7a108
Delete summitxl pkg and add somorob pkg
samFabrice Mar 6, 2023
7563127
create a pkg in order to record data
samFabrice Mar 6, 2023
ffba34d
Update the bag recoder node
samFabrice Mar 7, 2023
7e7c60d
Update the bag recoder node and summit_xl node
samFabrice Mar 7, 2023
1917deb
Add the correct topic name to the bag_recorder_cpp file
samFabrice Mar 7, 2023
6cff48d
Updated summit_xl.cpp file
samFabrice Mar 7, 2023
fab6e10
Correct CMAKEList.txt comment and delete unessary include in bag_reco…
samFabrice Mar 7, 2023
a903386
Create a test folder and move bag_record and somorob node into it
samFabrice Mar 9, 2023
3912adc
remove record files
samFabrice Mar 9, 2023
a8a483a
remove duplicated code
samFabrice Mar 9, 2023
6db87f8
Add python script to process join_state data
samFabrice Mar 14, 2023
a06fdb3
Update bag_recorder node in order to record summit_xl odom topic ins…
samFabrice Mar 14, 2023
77f0d83
Update bag_recorder node in order to correctly record summit_xl odom …
samFabrice Mar 15, 2023
6626181
WIP
samFabrice Mar 23, 2023
16cc272
WIP
samFabrice Mar 27, 2023
8f4e955
WIP
samFabrice Mar 27, 2023
b48394a
Update Readme file
samFabrice Jun 30, 2023
b6962f0
Update Readme file
samFabrice Jun 30, 2023
5631706
WIP
samFabrice Jun 30, 2023
c75c74d
WIP
samFabrice Jun 30, 2023
6afc2d2
WIP
samFabrice Jun 30, 2023
b50dd0e
Update Readme
samFabrice Jul 10, 2023
5d4a889
Update Readme
samFabrice Jul 10, 2023
2b6a490
WIP
samFabrice Jul 10, 2023
a7e9f75
WIP
samFabrice Jul 10, 2023
ee7e62a
WIP
samFabrice Jul 11, 2023
ed4d0b1
Update scene.py in order to avoid using ros with keybordController
samFabrice Jul 11, 2023
e798779
Update the README
samFabrice Jul 11, 2023
bd6023d
Add a teleop key controller
samFabrice Jul 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ build/
install/
log/
*.view
*.json
*.json
record_folder/
*.txt
249 changes: 248 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,249 @@
# prefab.MobileTrunk
The MobileTrunk's robot prefab for SoftRobots.
[![SoftRobots](https://img.shields.io/badge/info-on_website-purple.svg)](https://project.inria.fr/softrobot/)
[![SOFA](https://img.shields.io/badge/SOFA-on_github-blue.svg)](https://github.com/sofa-framework)
[![Ronotnik Automation](https://img.shields.io/badge/RonotnikAutomation-on_github-green.svg)](https://github.com/RobotnikAutomation)
[![Ros](https://img.shields.io/badge/Ros-on_readthedocs-chocolate.svg)](https://docs.ros.org/en/foxy/index.html)

The *MobileTrunk's* robot prefab for SoftRobots.

Index
-----

* [Requirement](#requirement)
* [Compile sofa](#compile-sofa)
* [Install Required dependencies](#install-required-dependencies)
* [Download and set up working space](#download-and-set-up-working-space)
* [Install *ROS* and set up working space](#install-ros-and-set-up-working-space)
* [Launch test](#launch-test)
* [Connecting the digital twin to the physical robot](#connecting-the-digital-twin-to-the-physical-robot)
* [License](#license)

Requirement
-----------
This prefab was developed as part of the SOMOROB project. The goal is to integrate a
deformable robotic trunk (softrobot) on a 4-wheeled mobile robot base equipped with
a LIDAR and to develop its digital twin equivalent. The deformable trunk is a project
[Echelon 3](https://www.inria.fr/en/interface-inria-centre-university-lille-demonstration-space)
developed by the Defrost team at INRIA. The mobile base is developed by the company
[Robotnik automation](https://robotnik.eu/)

Software version
---------------
The softwares are use with the following version :
- Python 3

The following Sofa plugins are required. version V21.12 is needed.

- SofaPython3
- BeamAdapter
- SoftRobots

The following python module are required :

- time
- threading
- math
- numpy
- dataclasses
- sys

Compile *SOFA*
--------------

Install Required dependencies
------------------------------------
For that follow these [instructions](https://www.sofa-framework.org/download/) (We will install the linux one)
<!--(The best way to add plugin to SOFA is explained [here](https://www.sofa-framework.org/community/doc/getting-started/video-tutorials/how-to-compile-a-plugin/))

- STLIB

```console
foo@bar:~$ git clone https://github.com/SofaDefrost/STLIB.git
```

- SoftRobots

```console
foo@bar:~$ git clone https://github.com/SofaDefrost/SoftRobots.git
```

- SofaPython3

```console
foo@bar:~$ git clone https://github.com/sofa-framework/SofaPython3
```

- BeamAdapter

```console
foo@bar:~$ git clone https://github.com/SofaDefrost/BeamAdapter
```
-->

Download and set up working space
---------------------------------

### Download the mobile trunk's prefab

Now that you have install SOFA binairy we can clone
prefab.MobileTrunk repository.

- Create a directory where you will put it
- Move into it and clone the last working version

```console
foo@bar:~$ git clone https://github.com/CRIStAL-PADR/prefab.MobileTrunk
```

### Set up working space
Open your bashrc and add the following lines in order to setup your working space
- Add to the PATH the path to the folder where the binary files are located

```console
export PATH="/path to binary folder/bin:$PATH"
```

- Tell to *SOFA_ROOT* the path where to find the path to the buid folder of SOFA

```console
export SOFA_ROOT=/path to binary folder
```

- Make an alias in order to be able to launch Sofa easily by doing a runSofa

```console
runSofa="/path to binary folder/bin/runSofa"
```

- Add to the PYTHONPATH the path to *SofaPython3*, *STLIB* , *SofaROS* , *Python3*
```console
export PYTHONPATH=$PYTHONPATH:"/path to binary folder/plugin/SofaPython3/lib/python3/site-packages":"/path to binary folder/plugin/STLIB/lib/python3/site-packages":"/usr/local/lib/python3.8/dist-packages":"/path to binary folder/plugin/SoftRobots/share/sofa/examples/SoftRobots/sofaros"
```

- Now you can source your .bashrc file with the command
```console
source ~/.bashrc
```

- And run the command:
```console
runSofa
```
If everything went well, you should see the Sofa GUI appear.

Now, click on the *Edit* button and go to *Plugin Manager*. Then click on *Add*. A window will appear. You need to navigate to the directory where the binary files are located. Go to the *plugins* directory, then to *ArticulatedSystemPlugin*, and then to *lib*. There, you will find a file named *libArticulatedSystemPlugin.so*. Click on *Open*.

Repeat the same procedure to add the *.so* files for the *SofaPython3* plugin.

Install *ROS* and set up working space
--------------------------------------

The digital twin has a *ros2* interface while the mobile platform (summit_xl) has a *ros1* interface.
It is possible to be able to link the digital twin to the real robot using rosbridge.

### Install ros2 and ros1

Install the [noetic](http://wiki.ros.org/noetic/Installation/Ubuntu) version for ros1 in order to be able to use rosbridge

Install the [foxy](https://docs.ros.org/en/foxy/Installation.html) version for ros2.

If you are new to ros you can follow the [tutorials](https://docs.ros.org/en/foxy/Tutorials.html) before continuing

Install rosbridge

```console
foo@bar:~$ sudo apt-get install -y ros-foxy-ros1-bridge
```

### Set up working space

Open your bashrc and add the following lines in order to setup your working space for ros

- Create an alias for noetic(ros1) and foxy(ros2) in order to be able to source your terminal more easily

```console
alias foxy="source /opt/ros/foxy/setup.bash"
alias noetic="source /opt/ros/noetic/setup.bash"
```

- Open sofaros.py file located in plugings/SoftRobots/share/sofa/examples/SoftRobots folder.
Then replace in the callback method of RosReceiver class the line
```console
self.data = data.data by self.data = data
```
Launch test
-----------
To confirm all the previous steps and verify that the prefab is working properly you can :

#### Test using sofa controller

- Launch the scene.py SOFA scene situated in prefab.MobileTrunk/mobile_trunk_sim by doing:
```console
foo@bar:~$ runSofa scene.py --argv KeyboardController
```
- If everything went well you should see the GUI Sofa with the digital twin of

![somorob](/docs/somorob.png)


- Then with your keyboard send velocity and orientation command to the Sofa scene in order to see the robot
move.


#### Test using ros api

- source your terminal using :
```console
foo@bar:~$ foxy
```

- Go to the directory where the prefab.MobleTrunk/mobile_trunk_sim folder is located and run
the following command:

```console
foo@bar:~$ runSofa scene.py --argv RobotToSim
```
- Open a new terminal then source it as before then execute the commands to the following command:

```console
foo@bar:~$ colcon build && . install/setup.bash && foxy
```

- You can now launch the keyboard controller to interact with the robot in the simulation

```console
foo@bar:~$ ros2 run summitxl summitxl_teleop_key

```

- If everything went well you should see this appear in the terminal

![ros_teleop_key](/docs/ros_teleopkey.png/)


## Echelon

### Controller

#### Forward kinematics

- ctl + i : To select the cable i (from 1 to 9) you want to actuate
- ctl + plus : if you want to pull the cable
- ctl + minus : if you want to release the cable

### Links

You can found the Echelon3 folder with the reference simulation there : https://gitlab.inria.fr/defrost/Robots/Echelon3.git with the branch Centrale_Dynamixel. The reference simulation is in the folder **simulation**.

There is also the ros2 package : https://gitlab.inria.fr/defrost/Robots/sim_echelon3_ros.git with the branch ros2.

You can find all the details and the explanation in this two repository.

Connecting the digital twin to the physical robot
-------------------------------------------------


License
-------

Creative Commons Zero v1.0 Universal see LICENSE
Binary file added docs/SOMOROB test validation.pdf
Binary file not shown.
Binary file added docs/prefab.MoblieTrunkPresentation.pdf
Binary file not shown.
Binary file added docs/ros_teleopkey.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/sofa.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/somorob.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions mobile_trunk_sim/addCamera.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
def addCamera(rootNode):

camera = rootNode.addChild('Camera')
camera.addObject('MechanicalObject' , template='Rigid3d', rotation=[180, 0, 0],position=[1.13687e-13, 260, 1078.45, -0.5, -0.5, 0.5, 0.5],
showObject=False, showObjectScale=100)

camera.addObject('RigidRigidMapping', name="mapping", input = rootNode.Trunk.framesNode.frames.getLinkPath() ,index=100)

rootNode.getRoot().addObject('OglViewport', screenSize=[320, 200], name='Camera', zNear=5,
zFar=-10, fovy=55,
cameraRigid=camera.MechanicalObject.position.getLinkPath(), useFBO=False)
55 changes: 55 additions & 0 deletions mobile_trunk_sim/echelon3/CableController.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import Sofa
import math

class CableController(Sofa.Core.Controller):
"""
Controller to control the cables in forward kinematics
Parameters :
cables : list of the cables (constraint object)
name : the name of the component
"""

def __init__(self, cables : list, name : str = "CableController"):
Sofa.Core.Controller.__init__(self, name = name)

self.cables = cables
self.index =0
# action at beginning frame
def onAnimateBeginEvent(self, eventType):
pass

#action when key press
def onKeypressedEvent(self, c):
key = c['key']
displacement = [math.inf]

##### cables number ######
if (key == "1"):
self.index = 0
elif (key == "2"):
self.index = 1
elif (key == "3"):
self.index = 2
elif (key == "4"):
self.index = 3
elif (key == "5"):
self.index = 4
elif (key == "6"):
self.index = 5
elif (key == "7"):
self.index = 6
elif (key == "8"):
self.index = 7
elif (key == "9"):
self.index = 8

##### add or substract ######
if key == '+':
displacement = self.cables[self.index].value.value+1
self.cables[self.index].value.value = [displacement]
print(f'Cables {self.index} displacement = {displacement[0]}')

elif key == '-':
displacement = self.cables[self.index].value.value-1
self.cables[self.index].value.value = [displacement]
print(f'Cables {self.index} displacement = {displacement[0]}')
61 changes: 61 additions & 0 deletions mobile_trunk_sim/echelon3/ForceController.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import Sofa


class ForceController(Sofa.Core.Controller):
"""
Controller to control the cables in forward kinematics
Parameters :
mechanicalObject : the mechanicalObject to control
dt : step time as in Sofa Force(Sofa) = Force(N) *dt
name : the name of the component
"""

def __init__(self, cables : list, dt : float, name : str = "CableController"):
Sofa.Core.Controller.__init__(self, name = name)

self.cables = cables
self.forceMax = 1e20 # max 6kg
self.forceMin = 0
self.dt = dt

# action at beginning frame
def onAnimateBeginEvent(self, eventType):
pass

#action when key press
def onKeypressedEvent(self, c):
key = c['key']

##### cables number ######
if (key == "1"):
self.index = 0
elif (key == "2"):
self.index = 1
elif (key == "3"):
self.index = 2
elif (key == "4"):
self.index = 3
elif (key == "5"):
self.index = 4
elif (key == "6"):
self.index = 5
elif (key == "7"):
self.index = 6
elif (key == "8"):
self.index = 7
elif (key == "9"):
self.index = 8

##### add or substract ######
if key == '+':
force = self.cables[self.index].value.value+981000*self.dt # F = g.mm.s-2 ==> 100g : 100*9810 = g.mm.s-2
if force[0] <= self.forceMax :
self.cables[self.index].value.value = [force]
print(f'Cables {self.index} force = {force[0]*1e-6}')

elif key == '-':
force = self.cables[self.index].value.value-981000*self.dt # F = g.mm.s-2 ==> 100g : 100*9810 = g.mm.s-2
if force[0] >= -self.forceMin :
self.cables[self.index].value.value = [force]
print(f'Cables {self.index} force = {force[0]*1e-6}')

Loading