Skip to content

Commit 7fa2e90

Browse files
committed
no irritating config function
1 parent eedce63 commit 7fa2e90

4 files changed

Lines changed: 14 additions & 21 deletions

File tree

src/bitbots_motion/bitbots_rl_motion/handlers/phase_handler.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,6 @@ def __init__(self, config):
1313
self._gait_frequency = self._config["phase"]["gait_frequency"]
1414
self._phase_dt = 2 * np.pi * self._gait_frequency * self._control_dt
1515

16-
def get_control_dt(self):
17-
return self._control_dt
18-
19-
def get_gait_frequency(self):
20-
return self._gait_frequency
21-
2216
def get_phase(self):
2317
return self._phase
2418

src/bitbots_motion/bitbots_rl_motion/nodes/rl_node.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,16 @@ class SubscriptionParam(NamedTuple):
4545
def __init__(self, config_path: str):
4646
self._config = self._load_config(config_path)
4747
self._obs = None # should be defined in subclass
48-
self._phase_handler = None # shoul be defined in subclass
48+
self._phase_handler = None # should be defined in subclass
49+
50+
self._timer = self.create_timer(self._config["phase"]["control_dt"], self._timer_callback)
51+
self.load_phase()
52+
53+
self._subs = []
54+
55+
for key, value in self.__dict__.values():
56+
if type(value) is Subscription:
57+
self._subs.append(key)
4958

5059
def _load_config(self, path: str):
5160
with open(path) as f:
@@ -68,7 +77,7 @@ def _timer_callback(self):
6877

6978
# TODO consider IMU mounting offset
7079

71-
self._timer_phase_config.set_obs_phase(
80+
self._phase_handler.set_obs_phase(
7281
np.array(
7382
[np.cos(self._phase_handler.get_phase()), np.sin(self._phase_handler.get_phase())],
7483
dtype=np.float32,
@@ -107,16 +116,6 @@ def load_model(self, model):
107116
for out in self._onnx_model.graph.output:
108117
self._onnx_output_name.append(out)
109118

110-
def config(self):
111-
self._timer = self.create_timer(self._timer_phase_config.get_control_dt(), self._timer_callback)
112-
self.load_phase()
113-
114-
self._subs = []
115-
116-
for key, value in self.__dict__.values():
117-
if type(value) is Subscription:
118-
self._subs.append(key)
119-
120119
def obs(self):
121120
# Should be defined in subclass
122121
pass

src/bitbots_motion/bitbots_rl_motion/nodes/walk_node.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ def __init__(self, config_path: str):
3636
self._command_handler = CommandHandler(self._config)
3737
self._phase_handler = PhaseHandler(self._config)
3838

39-
self.config()
40-
4139
# observations
4240

4341
self._obs = np.hstack(
@@ -64,6 +62,8 @@ def _joint_state_callback(self, msg):
6462
def _cmd_vel_callback(self, msg):
6563
self._command_handler.cmd_vel_callback(msg)
6664

65+
# load phase function
66+
6767
def load_phase(self):
6868
walkready_command = self._joint_handler.get_walkready_joint_command()
6969
self._joint_command_pub.publish(walkready_command)

src/bitbots_motion/bitbots_rl_motion/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<name>bitbots_rl_motion</name>
55
<version>0.0.0</version>
66
<description>TODO: Package description</description>
7-
<maintainer email="git@flova.de">florian</maintainer>
7+
<maintainer email="git@sWintermoor.de">florian</maintainer>
88
<license>TODO: License declaration</license>
99

1010
<test_depend>ament_copyright</test_depend>

0 commit comments

Comments
 (0)