ub-nsf-hsi / shasta-ub

https://ub-nsf-hsi.github.io/shasta-ub/
MIT License
1 stars 3 forks source link

shata.base_experiment issue #22

Closed Bunmsel closed 5 months ago

Bunmsel commented 5 months ago

Description

I was going through the tutorials from the website "https://ub-nsf-hsi.github.io/shasta-ub/html/tutorials/custom_experiments.html but while trying to run the code of custom experiment, I kept getting errors.

What I Did

from collections import defaultdict from shasta.base_experiment import BaseExperiment from .actions import SimpleActionDecoder from .custom_primitive import FormationWithPlanning from .states import StatesExtractor

def group_actors_by_type(actor_groups): actor_type = defaultdict(list) for key, value in sorted(actor_groups.items()): actor_type[value[0].type].extend(value) return actor_type

class SearchingExperiment(BaseExperiment): def init(self, config, core, experiment_config=None, *args, *kargs): super().init(config, core, experiment_config, args, **kargs) self.state_extractor = StatesExtractor(experiment_config, core) self.actions_decoder = SimpleActionDecoder(experiment_config) self.actions = {} env_map = core.get_map() for i in range(6): self.actions[i] = FormationWithPlanning(env_map)

def reset(self):
    pass

def get_action_space(self):
    pass

def get_observation_space(self):
    pass

def get_actions(self):
    pass

def apply_actions(self, actions, core):
    paretos = self.state_extractor.get_pareto_node()
    decoded_action = self.actions_decoder.get_action(actions, paretos)
    while True:
        actor_groups = core.get_actor_groups()
        self.actions_done = []
        for group_id, action_args in decoded_action.items():
            self.actions_done.append(
                self.actions[group_id].execute(actor_groups[group_id], action_args)
            )
        core.tick()
        if all(self.actions_done):
            for group_id in actor_groups.keys():
                self.actions[group_id].path_points = None
            break

def get_observation(self, observation, core):
    actor_groups = core.get_actor_groups()
    grouped_by_type = group_actors_by_type(actor_groups)
    states = self.state_extractor.get_state(
        grouped_by_type['uav'], grouped_by_type['ugv']
    )
    done = self.state_extractor.update_progrees(
        grouped_by_type['uav'], grouped_by_type['ugv']
    )
    return states, {"searching_done": done}

def get_done_status(self, observation, core):
    return self.actions_done

def compute_reward(self, observation, core):
    return 0

Here is the error below:

ModuleNotFoundError Traceback (most recent call last) in <cell line: 2>() 1 from collections import defaultdict ----> 2 from shasta.base_experiment import BaseExperiment 3 from .actions import SimpleActionDecoder 4 from .custom_primitive import FormationWithPlanning 5 from .states import StatesExtractor

ModuleNotFoundError: No module named 'shasta.base_experiment'

HemuManju commented 5 months ago

@Bunmsel, did you install the SHaSTA? The installation instructions are here: https://ub-nsf-hsi.github.io/shasta-ub/html/installation.html

Bunmsel commented 5 months ago

@HemuManju Yes, thank you. I was using the wrong evironment