This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
cs:ai:start [2018/02/23 18:02] Mike Bykhovtsev |
cs:ai:start [2018/02/24 00:15] Mike Bykhovtsev |
||
---|---|---|---|
Line 9: | Line 9: | ||
Advantages of SMACH are: | Advantages of SMACH are: | ||
- | - Ordered List Itemrapid development, ability to create complex state machines; | + | - rapid development, ability to create complex state machines; |
- ability to quickly change state machines without big code changes | - ability to quickly change state machines without big code changes | ||
- explicitly define outcomes of every state thus covering most or all possible situations. | - explicitly define outcomes of every state thus covering most or all possible situations. | ||
Line 23: | Line 23: | ||
- SubscribeState.py - a state that was made which accept also topic to which you want to subscribe. It is also modified to pass over any input/output keys. **In future this file will also contain SynchronousSubscribeState that subscribes to two topics and moves once it has two** | - SubscribeState.py - a state that was made which accept also topic to which you want to subscribe. It is also modified to pass over any input/output keys. **In future this file will also contain SynchronousSubscribeState that subscribes to two topics and moves once it has two** | ||
- | There is a useful tool to see state machine and transitions of it called smach_viewer. To run it run | + | There is a useful tool to see state machine and transitions of it called **smach_viewer**. To run it, run |
<code bash> | <code bash> | ||
rosrun smach_viewer smach_viewer.py | rosrun smach_viewer smach_viewer.py | ||
</code> | </code> | ||
+ | An example of what our AI looks like in smach_viewer is this screenshot below | ||
+ | {{ :cs:ai:gate_ai.png?nolink |}} | ||
+ | ===== Things to know when developing AI ===== | ||
+ | * When inheriting from **SubscribeState** instead of **SmachState**, you need to use **self.exit("outcome")** instead of **return "outcome"** | ||
+ | * Every python script that is going to run any state machine **must have** in its main function these lines of code below. | ||
+ | <code python> | ||
+ | while rospy.get_time() == 0: | ||
+ | continue | ||
+ | </code> | ||
+ | * Every time you create control_wrapper instance, you need to set depth value again. | ||
+ | * If your state is using control wrapper to move, right before final outcome make sure to set changed yaw/roll/pitch/forward to 0. | ||
+ | * Control wrapper forward and strafe do not use relative same way as yaw and pitch, use instead **strafeLeftError()** and **forwardError()** | ||
+ | * Some current AI files use parameters from roscore server for different configuration of values. They will crash if they do not load parameters. To load parameters run | ||
+ | <code bash> | ||
+ | rosparam load [param_file_name].yaml | ||
+ | </code> | ||
+ | * Every time you restart roscore you need to reload parameters | ||
+ | * Our vision detection requires undistortion to be running. |