swarmrl.tasks.object_movement.rod_rotation Module API Reference¶
Class for rod rotation task.
RotateRod
¶
Bases: Task
Rotate a rod.
Source code in swarmrl/tasks/object_movement/rod_rotation.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
__call__(colloids)
¶
Compute the reward.
In this case of this task, the observable itself is the gradient of the field that the colloid is swimming in. Therefore, the change is simply scaled and returned.
Parameters¶
colloids : List[Colloid] (n_colloids, ) List of colloids to be used in the task.
Returns¶
rewards : List[float] (n_colloids, ) Rewards for each colloid.
Source code in swarmrl/tasks/object_movement/rod_rotation.py
186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 |
|
__init__(partition=True, rod_type=1, particle_type=0, direction='CCW', angular_velocity_scale=1, velocity_history=100)
¶
Constructor for the find origin task.
Parameters¶
partition : bool (default=True) Whether to partition the reward by particle contribution. rod_type : int (default=1) Type of particle making up the rod. scale_factor : float (default=100.0) The amount the velocity is scaled by to get the reward. direction : Union[None, str] (default=None) Direction of the rod to rotate. If None, the rod will rotate arbitrarily. particle_type : int (default=0) Type of particle receiving the reward. velocity_history : int (default=100) Number of steps to average the velocity over.
Source code in swarmrl/tasks/object_movement/rod_rotation.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
|
initialize(colloids)
¶
Prepare the task for running.
In this case, as all rod directors are the same, we only need to take on for the historical value.
Parameters¶
colloids : List[Colloid] List of colloids to be used in the task.
Returns¶
Updates the class state.
Source code in swarmrl/tasks/object_movement/rod_rotation.py
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
|
partition_reward(reward, colloid_positions, rod_positions, rod_directors)
¶
Partition a reward into colloid contributions.
Parameters¶
reward : float Reward to be partitioned. colloid_positions : np.ndarray (n_colloids, 3) Positions of the colloids. rod_positions : np.ndarray (n_rod, 3) Positions of the rod particles. rod_directors : np.ndarray (n_rod, 3) Directors of the rod particles.
Returns¶
partitioned_reward : np.ndarray (n_colloids, ) Partitioned reward for each colloid.
Source code in swarmrl/tasks/object_movement/rod_rotation.py
119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
|