You are here

General motor module, redux.

So, I've been working on making it as simple as possible to add new movements to the motor module. I think I've got it down. To add new types of movements, you need to implement ICommandTranslatorDelegate, which has the following methods:

/**

* returns true if this delegate can handle a command as specified by

* this chunk pattern

* @param pattern

* @return

*/

public boolean handles(ChunkPattern pattern);

/**

* translate a string name into an {@link IEfferentObject} that represents the muscle.

* This is called during a buffer query that has been scoped on a specific muscle group

* @param muscleName

* @param model

* @return

* @throws IllegalArgumentException if no muscle is found

*/

public IEfferentObject getMuscle(String muscleName, IModel model) throws IllegalArgumentException;

/**

* translates a set of slot values into a IEfferentObject that represents

* a muscle defined within the pattern. Since many ACT-R movement commands use multiple slots

* to define a muscle, this collapses them. (i.e. translates hand right finger index into right-index).

* In addition to the returned IEfferentObject this method should also ensure that the slots

* used to define the muscle are nulled out and the muscle slot is specified.

* @throws IllegalArgumentException

*/

public IEfferentObject getMuscle(ChunkPattern pattern, IModel model) throws IllegalArgumentException;

/**

* translate a ChunkPattern into an appropriate IEfferentCommand. By setting the MovementCommand.MOVEMENT_RATE,

* the translator may provide a hint to common reality regarding the actual execution time of the movement.

* @return

* @throws IllegalArgumentException

*/

public IEfferentCommand translate(ChunkPattern pattern, IEfferentObject muscle, IModel model) throws IllegalArgumentException;

The abstract implementation AbstractTranslator already takes care of getMuscle(String,IModel), leaving just three methods. The formatting of the IEfferentCommand by translate() is where the magic happens. This requires some knowledge of CommonReality, but examples can be seen in org.jactr.modules.pm.motor.command.translators.

Once the ICommandTranslatorDelegate is implemented, it can be added to the model through the parameters section for the motor module:

<module class="org.jactr.modules.pm.motor.six.DefaultMotorModule6">

<parameters>

<parameter name="org.commonreality.player.actuators.motor.ptz.TurnHeadCommandDelegate" value="true"/>

</parameters>

</module>



And that's it. I'll post an explanation as to how to add handling on the sensor side, but I'm still cleaning up the generalized motor system for common reality (right now there are three different sensor systems all doing similar things and I'm refactoring to a common denominator).