Criterion
Criterion calculation
- class rostok.criterion.criterion_calculation.Criterion
- calculate_reward(simulation_output: SimulationResult)
The function that returns the reward as a result of the simulation.
- Args:
simulation_output (SimulationResult): the result of the simulation
- class rostok.criterion.criterion_calculation.FinalPositionCriterion(reference_distance: float, grasp_event_builder: EventGraspBuilder, slipout_event_builder: EventSlipOutBuilder)
Criterion based on the position change after applying testing force.
- Attributes:
reference_distance (float): reference distance for the criterion grasp_event (EventGrasp): event of object grasping slipout_event (EventSlipOut): event of object slip out
- calculate_reward(simulation_output: SimulationResult)
The reward is 1 - dist(position in the grasp moment, position in the final moment)/(reference distance)
- Returns:
float: reward of the criterion
- class rostok.criterion.criterion_calculation.ForceCriterion(event_timeout_builder: EventContactTimeOutBuilder)
Reward based on the mean force of the robot and object contact.
- Attributes:
event_timeout (EventContactTimeOut): event of contact time out
- calculate_reward(simulation_output: SimulationResult) float
- Return 0 if there is no contact. For every step where object is in contact with robot
the total force is added to a list and the final reward is calculated using the mean value of that list
- Returns:
float: reward of the criterion
- class rostok.criterion.criterion_calculation.GraspTimeCriterion(grasp_event_builder: EventGraspBuilder, total_steps: int)
Criterion based on the time before grasp.
- Attributes:
event_grasp (EventGrasp): event of object grasping total_steps (total_steps): the amount of the possible steps
- calculate_reward(simulation_output: SimulationResult)
Reward depends on the speed of the grasp.
- Returns:
float: reward of the criterion
- class rostok.criterion.criterion_calculation.InstantContactingLinkCriterion(grasp_event_builder: EventGraspBuilder)
Criterion based on the percentage of contacting links.
- Attributes:
event_grasp (EventGrasp): event of object grasping
- calculate_reward(simulation_output: SimulationResult)
The reward is the fraction of the links that contacts with object in the grasp moment.
- Returns:
float: reward of the criterion
- class rostok.criterion.criterion_calculation.InstantForceCriterion(grasp_event_builder: EventGraspBuilder)
Criterion based on the std of force modules.
- Attributes:
event_grasp (EventGrasp): event of object grasping
- calculate_reward(simulation_output: SimulationResult)
Calculate std of force modules in the grasp moment and calculate reward using it.
- Returns:
float: reward of the criterion
- class rostok.criterion.criterion_calculation.InstantObjectCOGCriterion(grasp_event_builder: EventGraspBuilder)
Reward based on the distance between object COG and force centroid.
- Attributes:
event_grasp (EventGrasp): event of object grasping
- calculate_reward(simulation_output: SimulationResult)
Calculate the reward based on distance between object COG and force centroid in the moment of grasp.
- Returns:
float: reward of the criterion
- class rostok.criterion.criterion_calculation.SimulationReward(verbosity=0)
Aggregate criterions and weights to calculate reward.
- Attributes:
criteria (List[Criterion]): list of criterions weights (List[float]): criterion weights verbosity (int): parameter to control console output
- add_criterion(citerion: Criterion, weight: float)
Add criterion and weight to the lists.
- Args:
citerion (Criterion): new criterion weight (float): weight of the new criterion
- calculate_reward(simulation_output, partial=False)
Calculate all rewards and return weighted sum of them.
- Args:
simulation_output (_type_): the results of the simulation
- Returns:
float: total reward
- class rostok.criterion.criterion_calculation.TimeCriterion(time: float, event_timeout_builder: EventContactTimeOutBuilder, event_grasp_builder: EventGraspBuilder)
Reward based on the time simulation if the grasp doesn’t happen.
- Attributes:
max_simulation_time (float): maximum simulation time event_timeout (EventContactTimeOut): event of contact time out event_grasp (EventGrasp): event of object grasping
- calculate_reward(simulation_output: SimulationResult)
- Return 1 for all robots that can grasp the object.
Return 0 if there is no contact. If the robot only touches the object and than lose contact, return reward that increases with time of the contact
- Returns:
float: reward of the criterion
Flag stop simulation
- class rostok.criterion.simulation_flags.EventCommands(value)
Commands available for the events. The simulation class handles these commands
- class rostok.criterion.simulation_flags.EventContact(take_from_body: bool = False)
Event of contact between robot and object
Attributes: from_body (bool): flag determines the source of contact information.
- event_check(current_time: float, step_n: int, robot_data: Sensor, env_data: Sensor)
Simulation calls that method each step to check if the event occurred.
- Args:
current_time (float): time from the start of the simulation step_n (int): step number of the simulation robot_data (_type_): current state of the robot sensors env_data (_type_): current state of the environment sensors
- class rostok.criterion.simulation_flags.EventContactTimeOut(ref_time: float, contact_event: EventContact)
Event that occurs if the robot doesn’t contact with body during the reference time from the start of the simulation.
- Attributes:
- reference_time (float): the moment of time where the simulation is interrupted
if there is no contact with the body
contact (bool): the flag that determines if there was a contact with body
- class rostok.criterion.simulation_flags.EventFlyingApart(max_distance: float)
The event that stops simulation if the robot parts have flown apart.
- Attributes:
max_distance (float): the max distance for robot parts
- class rostok.criterion.simulation_flags.EventGrasp(grasp_limit_time: float, contact_event: EventContact, verbosity: int = 0, simulation_stop: bool = False)
Event that activates the force if
- Attributes:
grasp_steps (int): the amount of consecutive steps body is not moving grasp_time (float): the moment of the grasp event contact (bool): the flag of body and object first contact activation_code (int): the activation code for ACTIVATE command grasp_limit_time (float): the time limit for the grasp event force_test_time (float): the time period of the force test of the grasp
- event_check(current_time: float, step_n: int, robot_data: Sensor, env_data: Sensor)
Return ACTIVATE if the body was in contact with the robot and after that at some point doesn’t move for at least 10 steps. Return STOP if the grasp didn’t occur during grasp_limit_time.
- Returns:
EventCommands: return a command for simulation
- reset()
Reset the values of the attributes for the new simulation.
- class rostok.criterion.simulation_flags.EventSlipOut(ref_time)
The event that stops simulation if the body slips out from the grasp after the contact.
- Attributes:
time_last_contact (float): time of last contact of robot and body reference_time (float): time of contact loss until the stop of the simulation
- event_check(current_time: float, step_n: int, robot_data: Sensor, env_data: Sensor)
Return STOP if the body and mech lose contact for the reference time.
- Returns:
EventCommands: return a command for simulation
- reset()
Reset the values of the attributes for the new simulation.
- class rostok.criterion.simulation_flags.EventStopExternalForce(grasp_event: EventGrasp, force_test_time: float)
Event that controls external force and stops simulation after reference time has passed.
- event_check(current_time: float, step_n: int, robot_data, env_data)
STOP simulation in force_test_time after the grasp.
- class rostok.criterion.simulation_flags.SimulationSingleEvent(verbosity=0)
The abstract class for the event that can occur during the simulation only once.
At each step of the simulation the event is checked using the current states of the sensors. step_n is a single value because the event can occur only once in simulation.
- Attributes:
state (bool): event occurrence flag step_n (int): the step of the event occurrence verbosity (int): controls the console output of the event
- abstract event_check(current_time: float, step_n: int, robot_data: Sensor, env_data: Sensor)
Simulation calls that method each step to check if the event occurred.
- Args:
current_time (float): time from the start of the simulation step_n (int): step number of the simulation robot_data (_type_): current state of the robot sensors env_data (_type_): current state of the environment sensors
- reset()
Reset the values of the attributes for the new simulation.