-
Notifications
You must be signed in to change notification settings - Fork 16
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
Following instructions in tutorial_custom_env fails on first step #30
Comments
Interesting, I haven't experienced this error befeore. @mx781 any idea? |
Hi @dfm794 - thanks for flagging, will look into it this week - sorry for the delay! |
@dfm794 super sorry for the long delay - I finally got a chance to look into the issue. Here's what missing in the tutorial:
[node name="SpawnPoint" type="Spatial" parent="."]
transform = Transform( 1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0 ) At that point, hitting play should work. FYI the scene_root hard-coding is expected - main.tscn (or any level for that matter) is loaded in code, as opposed to by changing the project settings. I will update the tutorial to fix this - thanks for reporting! |
@mx781 Thanks for this information... I wanted to feedback back the results of making these mods and ask a followup question... So, I went to my working directory which was in the same state as when the bug was filed. I made the two changes and had mixed results. That is, now when I ran the scene main.tscn. I was no longer placed in the 'avalon' environment..the window showed custom env as described in main. However, the crash happened as before. I diffed the directory against avalon/datagen/godot and saw no unexpected diffs. So..I started over from scratch just to be sure and encountered something strange. That is, if I started godot_editor in the copied avalon/datagen/godot directory, I got an error 'No config file given'. Clearly there is a config.json in the working directory. Specifying that config file with the --config-file flag resulted in a whole series of message of the form: SCRIPT ERROR: Invalid get index '1' (on base: 'Array'). I could not find anyway out of this..eventually, I just launched godot_editor outside this directory and then I was able to import the project.godot file, open main.tscn and run the game. However, when the game launches (and this was true previously as well), the scene is not still. The scene is rotating and the keyboard navigation controls, while they have an effect, it doesn't seem to me that it responds as expected. I understand there are a bunch of items here perhaps not directly related to the bug, I apologize of that, but as far as I know there is no discord or other communication channel to get help here and I would like to get this to work to the point I can evaluate if Avalon is useful for doing my experiments. I'm getting the impression that there are a bunch of assumptions not in the docs/readmes that i'm stumbling over. |
Hm, I suspect the likely assumption that's not spelled out in our docs is that you want to be using the custom editor and binary, available here. |
That requirement is spelled out. but of course it's worth validating. python -m avalon.install_godot_binary --overwrite Then validating with check install I placed the godot binary at the head of my path as well as setting the GODOT_BINARY_PATH env var. finally, the output from the launch of the editor shows the correct version.. I'm sure I'm missing something as I beleive you must be using it every day in your research. But I can't see what it is. |
Some additional issues from this tutorial. from avalon.common.log_utils import configure_local_logger
configure_local_logger() Step 4 does not work...
env = SphereEaterEnv(
config=create_base_benchmark_config(),
observation_type=SphereEaterObservation,
action_type=VRAction,
goal_evaluator=SphereEaterGoalEvaluator()
)
I tried the naive thing thing of adding a new definition of get_exposed_features() to the SphereEaterObservation class, but this complained about missing arguments to init(). |
Okay, seems like something more intricate is going on. I will try to work my way through the tutorial from scratch to make sure any recent changes haven't broken any of the steps here. I'll try to get back to you by tomorrow. |
Apologies for more delays. Let's take it one issue at a time:
This is correct - you shouldn't need to change this to follow this tutorial (and I was able to verify it works - does it not for you?). Your broader intuition is correct and skipping this detail was done for the simplicity of the tutorial, but I can see how it is misleading. The additional change you need to introduce is in # ...
interactive_observation["is_sphere_eaten"] = [null, TYPE_INT, [1]]
return interactive_observation Adding that should let it work with Let me know if you hit any more snags - I will update the tut to include this as well. |
@mx781 Sorry for the delay, I was traveling. I've rerun from scratch to validate all the steps. Let me address you questions and then enumerate changes that need to be made for the tutorial to work and finally open questions.
I see I made my reply too complicated. Let me rephrase this. Step 1 works as expected with your edits. Note that this seems to happen repeatedly and in other example, like the add task tutorial
I have done further investigation on this behavior and it seems to be related to remote X display. output of the commands you asked for: git rev-parse HEAD git diff
The above here is all dealing with Step 4 adding a goal evaluator. Now for the confusing part.. Finally, if I do add it, and add the lines you suggest to get_available_features, it does not change the behavior. Here's my function and the stack trace
InvalidObservationType Traceback (most recent call last) File ~/anaconda3/envs/avalon-pip-custom-sphere/lib/python3.9/site-packages/avalon/datagen/godot_env/godot_env.py:129, in GodotEnv.init(self, config, observation_type, action_type, goal_evaluator, gpu_id, is_logging_artifacts_on_error_to_s3, s3_bucket_name, is_error_log_checked_after_each_step, is_observation_space_flattened, is_godot_restarted_on_error, is_dev_flag_added, run_uuid) File ~/anaconda3/envs/avalon-pip-custom-sphere/lib/python3.9/site-packages/avalon/datagen/godot_env/observations.py:88, in GodotObservationContext.init(self, observation_type, is_space_flattened, available_features) File ~/anaconda3/envs/avalon-pip-custom-sphere/lib/python3.9/site-packages/avalon/datagen/godot_env/observations.py:106, in GodotObservationContext._select_features(self) InvalidObservationType: Could not find requested feature 'is_sphere_eaten'. Available features are: ['target_head_position', 'target_left_hand_position', 'target_right_hand_position', 'target_head_rotation', 'target_left_hand_rotation', 'target_right_hand_rotation', 'physical_body_position', 'physical_head_position', 'physical_left_hand_position', 'physical_right_hand_position', 'physical_body_rotation', 'physical_head_rotation', 'physical_left_hand_rotation', 'physical_right_hand_rotation', 'physical_body_linear_velocity', 'physical_head_linear_velocity', 'physical_left_hand_linear_velocity', 'physical_right_hand_linear_velocity', 'physical_head_angular_velocity', 'physical_left_hand_angular_velocity', 'physical_right_hand_angular_velocity', 'physical_body_delta_position', 'physical_head_delta_position', 'physical_left_hand_delta_position', 'physical_right_hand_delta_position', 'physical_head_relative_position', 'physical_left_hand_relative_position', 'physical_right_hand_relative_position', 'physical_head_relative_rotation', 'physical_left_hand_relative_rotation', 'physical_right_hand_relative_rotation', 'physical_body_delta_rotation', 'physical_head_delta_rotation', 'physical_left_hand_delta_rotation', 'physical_right_hand_delta_rotation', 'physical_body_delta_linear_velocity', 'physical_head_delta_linear_velocity', 'physical_left_hand_delta_linear_velocity', 'physical_right_hand_delta_linear_velocity', 'physical_head_delta_angular_velocity', 'physical_left_hand_delta_angular_velocity', 'physical_right_hand_delta_angular_velocity', 'left_hand_thing_colliding_with_hand', 'left_hand_held_thing', 'right_hand_thing_colliding_with_hand', 'right_hand_held_thing', 'physical_body_kinetic_energy_expenditure', 'physical_body_potential_energy_expenditure', 'physical_head_potential_energy_expenditure', 'physical_left_hand_kinetic_energy_expenditure', 'physical_left_hand_potential_energy_expenditure', 'physical_right_hand_kinetic_energy_expenditure', 'physical_right_hand_potential_energy_expenditure', 'fall_damage', 'hit_points_lost_from_enemies', 'hit_points_gained_from_eating', 'reward', 'hit_points', 'is_dead', 'nearest_food_position', 'nearest_food_id', 'is_food_present_in_world', 'is_done', 'episode_id', 'frame_id', 'rgbd']
One last issue with the tutorial in Step 5. So, to summarize what I see as changes to run the tutorial so far. after opening the editor, open main.tscn, as scene defaults to something else. Step 3 Step 4 Thanks for you help. I do think avalon could be useful for my work and I'm quite a ways into the add task tutorial. |
Thanks for summarizing all the changes to get things working! Can you confirm you were able to complete the tutorial with those changes applied? Or is there still something outstanding; it was not quite clear from your last message. |
Sure...yes, there are still three issues...one major and two minor ones. Let's walk through them. Major: Adding feature 'is_sphere_eaten' fails
When I did this, it did not work, as I wrote above. After debugging I discovered the issue. That is, the game code that is running when using godot_editor is not the same as is used when running godot via the gym interface. Why? When you follow the tutorial instructions, you copy the game code via rsync
Then the tutorial instructs you to modify gdscript code here. When you run the editor, you open a specific project and when you run from within the editor the gdscript game code executed is the code from this project directory. However, when you create an environment and run the code from python via the gym interface, the game code that is running is whatever was installed (in my case via pip install avalon). This seems like a big deal So,(if there is a way to do so) the tutorial code needs to have godot run the game code that one is instructed to copy and modify in the instructions -and if that is not possible, the instructions have to change to modify the code in both places. Ok, that's the major issue. Now the two minor ones. Minor: is_done code needs to change for step 5 Minor: agent is not facing sphere in step 5 That I think is the last three pieces to have the tutorial work 'out of the box' from the instructions. In full disclosure, I did not try Step 6 |
Thanks again for the thoroughness on these comments! The divergence of the two directories is indeed really confusing, thanks for highlighting it, I now realize this is a very sneaky distinction for the user. In essence, when the tutorial says "Godot can be a bit fiddly when you edit files underneath it while the editor is running", this should've really said something like "if you want to play with the environment in the editor itself, you should run It sounds like the only bit you weren't able to debug through is the last piece where you say "the sphere is slightly off to the left". Is this also happening when you're not using the remote X display? |
Thanks for the kind words... This came about because as I go through the tutorial, I'm copy-pasting from the tutorial dot md file to a jupyter notebook. The previous execution at the end of Step 4 is repeating what's in Step 2, which a change to the environment creation to use the SphereEater classes.
Note that this code does not do an env.reset() after the episode. Then Step 5's code in the tutorial does not reset before execution...
So net net - the Sphere is just wherever it was at the end of the 'random_env_step()' executed in the previous cell. If I just insert env.reset() early, all works as expected.
So, I think it would be useful to add this reset call to the tutorial code. |
Alright, great! Will collate all these changes into a PR and close when merged. |
Great. If you'd like me to run though it again post the PR to validate, I can do that. Just let me know |
I'm trying to walk through the instruction in the README.md file to create a custom environment.
Summarizing, the steps I took were to copy avalon/datagen/godot to another location, per instructions
rsync -r ./avalon/datagen/godot/ <my_path>/sphere_eater --info=progress2
copy main.tscn and sphere.gd to <my_path>/sphere_eater
then launch the godot_editor, import project.godot
When this is done, a top level scene is already open - scene_root
Ignoring that, I open main.tscn and see the expected cube and sphere.
Next step is to run the environment. This however launches an avalon environment rather than the custom one, as
project settings -> Application -> run -> Main Scene points to the scene_root.tscn file
Setting project settings -> Application -> run -> Main Scene to the main.tscn file however results in a fault at
res://game/game_manager/game_manager.gd:46 - at function _init
which is the line scene_root.add_child(node) line in this loop
for node in controlled_nodes:
scene_root.add_child(node)
The error message is
Attempt to call function 'add-child' in base 'null instance' on a null instance
It seems that scene_root is hardwired? Rather than using the node passed in to the init function as _root?
The text was updated successfully, but these errors were encountered: