|Tekkotsu Homepage||Demos||Overview||Downloads||Dev. Resources||Reference||Credits|
MirageComm Class Reference
Handles communication with Mirage to place and control an object in the environment. More...
Handles communication with Mirage to place and control an object in the environment.
The MirageComm constructor will open a connection to Mirage (if not already open). Then call setName() to register a name for your object. Finally, assign a KinematicJoint via setKinematics() to provide information to configure and display your object.
You can reuse the MirageComm instance for multiple objects in Mirage, simply call setName() to change the name of the object being controlled. Alternatively, you can use multiple MirageComms with a single shared network connection. Each MirageComm tracks the name of the object is controlling and sends this state in each update to Mirage.
Objects are kept in the Mirage simulation until all network connections associated with that object are closed. However, if setPersist(true) is called, the object will be kept active even if all associated network connections are closed.
#include "local/DeviceDrivers/MirageComm.h" #include "Wireless/netstream.h" ionetstream net; MirageComm mirage(net); // without arguments, makes connection to "localhost" mirage.setName("target"); mirage.setPersist(true); // so we can close net without removing object KinematicJoint * k = new KinematicJoint; // this will hold object description k->model="Sphere"; k->material="Pink"; k->modelScale=plist::Point(15,15,15); mirage.setKinematics(k); // mirage will delete k after the flush mirage.setPosition(500,0,0); // place object at (500,0,0) mm // mirage destructor will automatically flush assigned attributes // at end of scope, or you can call mirage.flush()
When you want to close the connection (e.g. remove the object "target" from previous example) just close the ionetstream connection. If you want to be "nice" about this, let MirageComm do it:
ionetstream net; // or continue 'net' scope from above to avoid connection overhead MirageComm mirage(net); mirage.setName("target"); mirage.setPersist(false); // disable persistance, object will be removed when 'net' is closed mirage.close(); // sends XML closing tags to make Mirage's parser feel warm and fuzzy
Note that if you can match the network connection scope to the desired lifetime of the object in Mirage (e.g. make 'net' a class member of your object's controller), then you don't need to call setPersist(), and can simply rely on objects being "garbage collected" when you eventually close the connection.
Constructor & Destructor Documentation
Member Function Documentation
Indicates which object is being controlled.
If an object with this name already exists, subsequent 'set' calls will control that object. If no such object exists, a new one will be created. This implies a flush if any parameters have been set under the old name.
If no name has been set yet, inherit parameters (i.e. doesn't flush parameters without a name)
Member Data Documentation
The documentation for this class was generated from the following file:
Tekkotsu Hardware Abstraction Layer 5.1CVS
||Generated Mon May 9 05:01:41 2016 by Doxygen 1.6.3|