Skip to content
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

State file name overwritten in Behavior source code when saving #14

Closed
RhysMcK opened this issue Apr 9, 2018 · 5 comments
Closed

State file name overwritten in Behavior source code when saving #14

RhysMcK opened this issue Apr 9, 2018 · 5 comments
Assignees

Comments

@RhysMcK
Copy link

RhysMcK commented Apr 9, 2018

I have pulled the latest development repo in order to utilise the new 'update state when source code changes' feature. However I seem to have come across a bug which prevents me from running the behavior. Every time I save the behavior the file name of the State ( in this case- jp_picking_main.py) changes in the behavior source code. As seen below on 2nd last line.

Expected Behavior Source Code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
###########################################################
#               WARNING: Generated code!                  #
#              **************************                 #
# Manual changes may get lost if file is generated again. #
# Only code inside the [MANUAL] tags will be kept.        #
###########################################################

from flexbe_core import Behavior, Autonomy, OperatableStateMachine, ConcurrencyContainer, PriorityContainer, Logger
from kr3_flexbe_states.jp_picking_main import JP_FindAndPick
from flexbe_states.log_state import LogState

Actual Behavior Source Code:

#!/usr/bin/env python
# -*- coding: utf-8 -*-
###########################################################
#               WARNING: Generated code!                  #
#              **************************                 #
# Manual changes may get lost if file is generated again. #
# Only code inside the [MANUAL] tags will be kept.        #
###########################################################

from flexbe_core import Behavior, Autonomy, OperatableStateMachine, ConcurrencyContainer, PriorityContainer, Logger
from kr3_flexbe_states..goutputstream-C9ESGZ import JP_FindAndPick
from flexbe_states.log_state import LogState

I then proceed to get the following output when running the behavior :

[07:55:57] --> Starting new behavior...
[07:55:57] Exception caught in behavior definition: [-]
    invalid syntax (tmp_-826516856.py, line 12)
[07:55:57] No behavior active.
[07:55:57] Dropped behavior start request because preparation failed.

Any thoughts? cheers!

@RhysMcK
Copy link
Author

RhysMcK commented Apr 9, 2018

After doing some further testing this seems to just be a bug with flexbe_full.launch. I am able to save the behavior and also make online edits to the state source file when using flexbe_ocs.launch without any issues. I can then open flexbe_full.launch to run the behavior. However, if i make any changes which require me to resave the behavior when in flexbe_full, the file name of the state will be overwritten as detailed above.

@pschillinger
Copy link
Member

pschillinger commented Apr 10, 2018 via email

@pschillinger
Copy link
Member

I was able to reproduce the issue and it looks like the following is going on:

When using some editor commands, for example "subl -n $FILE" for sublime, all works fine.

However, when using some other editor commands, including the default one "gedit --new-window $FILE +$LINE", the described issue occurs. The reason is that gedit creates a temporary file called ".goutputstream-xxxxxx", changes this file, and finally renames it to the target file again. As a consequence, the "change" event assumes a wrong file name.

@pschillinger
Copy link
Member

I changed the condition to determine whether a state definition update should be performed. It works for me now.

Can you confirm?

@RhysMcK
Copy link
Author

RhysMcK commented Apr 10, 2018

Thanks @pschillinger , that did it. Works a treat!

alireza-hosseini pushed a commit to alireza-hosseini/flexbe_app that referenced this issue Jun 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants