Skip to content

Commit f00df14

Browse files
author
Libor Wagner
committed
fix: ValueError: mutable default
1 parent e1639ef commit f00df14

1 file changed

Lines changed: 11 additions & 11 deletions

File tree

lbr_demos/lbr_moveit/lbr_moveit/forward_keyboard_node.py

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from dataclasses import dataclass
1+
from dataclasses import dataclass, field
22

33
import numpy as np
44
import rclpy
@@ -25,8 +25,8 @@ class Rotation:
2525
z: float = 0.0
2626

2727
joints: list
28-
translation: Translation = Translation()
29-
rotation: Rotation = Rotation()
28+
translation: Translation = field(default_factory=Translation)
29+
rotation: Rotation = field(default_factory=Rotation)
3030

3131
@dataclass
3232
class KeyboardLayout:
@@ -47,9 +47,9 @@ class Z:
4747
increase: str = "q"
4848
decrease: str = "e"
4949

50-
x: X = X()
51-
y: Y = Y()
52-
z: Z = Z()
50+
x: X = field(default_factory=X)
51+
y: Y = field(default_factory=Y)
52+
z: Z = field(default_factory=Z)
5353

5454
@dataclass
5555
class Rotation:
@@ -68,13 +68,13 @@ class Z:
6868
increase: str = "y"
6969
decrease: str = "h"
7070

71-
x: X = X()
72-
y: Y = Y()
73-
z: Z = Z()
71+
x: X = field(default_factory=X)
72+
y: Y = field(default_factory=Y)
73+
z: Z = field(default_factory=Z)
7474

7575
joints: list
76-
translation: Translation = Translation()
77-
rotation: Rotation = Rotation()
76+
translation: Translation = field(default_factory=Translation)
77+
rotation: Rotation = field(default_factory=Rotation)
7878
escape: str = "Key.esc"
7979
pause: str = "p"
8080
reverse_joints: str = "r"

0 commit comments

Comments
 (0)