-
Notifications
You must be signed in to change notification settings - Fork 22
Framework/bitbots rl motion #788
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
base: main
Are you sure you want to change the base?
Changes from all commits
7f03814
872c55b
56bbfbc
fa28e87
bea2bf0
a4d9c29
ca6b18f
00f2925
dd28ecb
431d1bd
8043366
9677784
976e0d9
8bfd972
ae88760
e9bbd94
2d1adf7
8276efc
ad9a5c2
31d8a83
5829e6d
65d64db
5935ca6
3c2afeb
c547090
251c08d
818ba4d
f21b7bd
96560ea
8e226e9
4e2c328
c4f5003
027ac43
57b638d
84ee120
92d8848
fec0b39
631475f
ff6a3ea
98e3e98
01149e2
c2ee62a
e380a03
3bc4e50
03ae24c
ae8b277
d22dd9d
341cb6a
15d41a2
eedce63
7fa2e90
bbcb1f1
a92aebc
b4789af
11f1da6
bfb13b4
f066501
1a92e74
e7da5e6
5bba14b
c1e6e7e
fedd633
f847afa
d7e8818
bf60258
139e8aa
73a4a99
f1e9881
cb30aeb
be9bf5a
e1bfaaf
c039cb0
1b05e34
6640b4b
4a937ac
f44c21f
650c38b
db9759f
cea5668
fea2b13
293f5ac
8004723
2e98274
0330ed4
ac6f5b0
6ebacba
73f9995
36d0c92
b0c7445
525d3db
2cc44e6
914d6a1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,7 @@ wolfgang_hardware_interface: | |
| servos: | ||
| # specifies which information should be read | ||
| read_position: true | ||
| read_velocity: false | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What are the velocities used for? |
||
| read_velocity: true | ||
| read_effort: false | ||
| read_pwm: false | ||
| read_volt_temp: true # this also corresponds for the error byte | ||
|
|
@@ -61,7 +61,7 @@ wolfgang_hardware_interface: | |
| Position_D_Gain: 0 #2800 # [/16] 0~16,383 | ||
| Position_I_Gain: 0 #180000 # [/ 65,536] 0~16,383 | ||
| #If robot starts to tremble, reduce Position_P_Gain | ||
| Position_P_Gain: 1200 #1100 # [/ 128] 0~16,383 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are we changing these P-gain values? Can we still walk as usual with this? |
||
| Position_P_Gain: 300 #1100 # [/ 128] 0~16,383 | ||
| Feedforward_2nd_Gain: 0 # [/4] | ||
| Feedforward_1st_Gain: 0 # [/4] | ||
| Profile_Acceleration: 0 # 0 for infinite | ||
|
|
@@ -89,7 +89,7 @@ wolfgang_hardware_interface: | |
| Position_D_Gain: 0 #2800 # [/16] 0~16,383 | ||
| Position_I_Gain: 0 #180000 # [/ 65,536] 0~16,383 | ||
| #If robot starts to tremble, reduce Position_P_Gain | ||
| Position_P_Gain: 800 #1100 # [/ 128] 0~16,383 | ||
| Position_P_Gain: 1100 #1100 # [/ 128] 0~16,383 | ||
| Feedforward_2nd_Gain: 0 # [/4] | ||
| Feedforward_1st_Gain: 0 # [/4] | ||
| Profile_Acceleration: 0 # 0 for infinite | ||
|
|
@@ -117,7 +117,7 @@ wolfgang_hardware_interface: | |
| Position_D_Gain: 0 #2800 # [/16] 0~16,383 | ||
| Position_I_Gain: 0 #180000 # [/ 65,536] 0~16,383 | ||
| #If robot starts to tremble, reduce Position_P_Gain | ||
| Position_P_Gain: 4000 #1100 # [/ 128] 0~16,383 | ||
| Position_P_Gain: 600 #1100 # [/ 128] 0~16,383 | ||
| Feedforward_2nd_Gain: 0 # [/4] | ||
| Feedforward_1st_Gain: 0 # [/4] | ||
| Profile_Acceleration: 0 # 0 for infinite | ||
|
|
@@ -145,7 +145,7 @@ wolfgang_hardware_interface: | |
| Position_D_Gain: 0 #2800 # [/16] 0~16,383 | ||
| Position_I_Gain: 0 #180000 # [/ 65,536] 0~16,383 | ||
| #If robot starts to tremble, reduce Position_P_Gain | ||
| Position_P_Gain: 500 #1100 # [/ 128] 0~16,383 | ||
| Position_P_Gain: 100 #1100 # [/ 128] 0~16,383 | ||
| Feedforward_2nd_Gain: 0 # [/4] | ||
| Feedforward_1st_Gain: 0 # [/4] | ||
| Profile_Acceleration: 0 # 0 for infinite | ||
|
|
||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| ## General | ||
|
|
||
| The package contains a framework which is a capsule for the application of policies on a robot. | ||
|
|
||
| ## Framework structure | ||
|
|
||
| The code is divided in five sections: Configs, Handlers, Nodes, Launch and rest. | ||
|
|
||
| The Nodes-folder contains all relevant ROS-Nodes regarding policy models. These nodes are responsible for starting the policies correctly, feeding them with correct data and publishing their outputs correctly. | ||
| The name of the node describes for which kind of policy it is suitable. | ||
| The RL Node is a special case. All other nodes are kids of the RL Node. It centralizes the execution loop and minimizes boiler plate code. | ||
|
|
||
| The Handlers-folder contains all handlers. A handler is a specific type of object which is responsible for processing external data such that they are comprehensible for the policy models. All handlers are kids of the Handler class. | ||
|
|
||
| The Configs-folder contains all robot/policy specific configurations. Files in the Configs-folder should be in .yaml-format. They also contain the paths to the onnx-policy models. | ||
|
|
||
| The Launch-folder contains a launch file which starts all relevant policy nodes. | ||
|
|
||
| phase.py and previous_action.py are two files, which do not fall in any of the aforementioned categories. | ||
| phase.py defines a PhaseObject, which is responsible for the phase management. previous_action.py defindes a PreviousAction object, which is responsible for saving and provide the previous action. | ||
| Both files are located in the bitbots_rl_motion folder. | ||
|
|
||
| ## Execution | ||
|
|
||
| For proper starting you need a policy model and a config file. The config file should have the same structure as the wolfgang_dribbling_model_config.yaml file. | ||
| Furthermore, you have to create or adjust a node file to your needs. walk_node.py can be used for orientation. If chages are conducted on the RL_Node class, it should be announced. | ||
| Finally, you define which nodes and policies you wanna use in the launch file. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| import numpy as np | ||
| from rclpy.node import Node | ||
|
|
||
| # Please pay attention to the code in rl_node.py if you wanna change here sth. | ||
|
|
||
|
|
||
| class PhaseObject(Node): | ||
| _phase: np.ndarray = np.array([0.0, np.pi], dtype=np.float32) | ||
| _phase_dt: float | ||
|
|
||
| def __init__(self, config): | ||
| if self.config["phase"]: | ||
| self._control_dt = config["phase"]["control_dt"] | ||
| self._gait_frequency = config["phase"]["gait_frequency"] | ||
| self._phase_dt = 2 * np.pi * self._gait_frequency * self._control_dt | ||
| else: | ||
| self._control_dt = None | ||
| self._gait_frequency = None | ||
| self._phase_dt = None | ||
| self.get_logger().warning("No phase was found! Using policy without phase!") | ||
|
|
||
| self._obs_phase = None | ||
|
|
||
| def set_phase(self, new_phase): | ||
| self._phase = new_phase | ||
|
|
||
| def set_obs_phase(self, new_obs_phase): | ||
| self._obs_phase = new_obs_phase | ||
|
|
||
| def get_phase(self): | ||
| return self._phase | ||
|
|
||
| def get_phase_dt(self): | ||
| return self._phase_dt | ||
|
|
||
| def get_obs_phase(self): | ||
| return self._obs_phase |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| import numpy as np | ||
|
|
||
|
|
||
| class PreviousActionObject: | ||
| def __init__(self, config): | ||
| self._previous_action: np.ndarray = np.zeros( | ||
| len(config["joints"]["ordered_relevant_joint_names"]), dtype=np.float32 | ||
| ) | ||
|
|
||
| def set_previous_action(self, new_previous_action): | ||
| self._phase = new_previous_action | ||
|
|
||
| def get_previous_action(self): | ||
| return self._previous_action |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I Currently no angle is set, but there are some parameters normally used by the angle estimation in the constructor.