Tekkotsu Homepage | Demos | Overview | Downloads | Dev. Resources | Reference | Credits |
MirageComm Class ReferenceHandles communication with Mirage to place and control an object in the environment. More...
Detailed DescriptionHandles 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. Parameters assigned by MirageComm are buffered until MirageComm hits its destructor, setName(), or flush() is called. 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. Definition at line 55 of file MirageComm.h.
Constructor & Destructor Documentation
Constructor, if io is not already connected, it will reconnect to host and port. If the connection fails, no status is returned, check io.is_open() or the MirageComm bool cast Definition at line 59 of file MirageComm.h.
destructor Definition at line 65 of file MirageComm.h. Member Function Documentation
Closes connection to Mirage. Any objects which have not had setPersist(true) and have not been "touched" by other connections will be removed from the environment. Definition at line 79 of file MirageComm.h.
Will cause previous 'set' calls to be transmitted to Mirage. Definition at line 174 of file MirageComm.h. Referenced by close(), setName(), and ~MirageComm().
returns true if the communication socket is still good Definition at line 185 of file MirageComm.h.
Assigns a value to a specific field of the root kinematic object. Many times no joints are in use, and you only want to modify a subset of fields, without respecifying the kinematic description—this will let you do it. Definition at line 116 of file MirageComm.h.
Assigns kinematic information to define the display and movement of the object, will delete kj after flush! This will delete kj after the next flush, so pass the result of kj->clone() if you don't want to lose your instance Definition at line 106 of file MirageComm.h.
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) Definition at line 91 of file MirageComm.h.
Controls orientation of the object. Definition at line 166 of file MirageComm.h.
If passed 'true', this will prevent the current object from being removed when the connection is closed. Definition at line 99 of file MirageComm.h.
Controls position of the object. Definition at line 160 of file MirageComm.h.
Controls position of the object. Definition at line 155 of file MirageComm.h.
Controls position of the object. Definition at line 150 of file MirageComm.h.
Controls position of the object. Definition at line 145 of file MirageComm.h.
Controls position of the object. Definition at line 140 of file MirageComm.h. Member Data Documentation
connection to Mirage Definition at line 188 of file MirageComm.h. Referenced by close(), connect(), flush(), MirageComm(), and operator bool().
buffers settings to Mirage until flush(); Definition at line 190 of file MirageComm.h. Referenced by flush(), setKinematicProperty(), setKinematics(), setOrientation(), setPersist(), setPosition(), and ~MirageComm().
name ("ID") of the current object in Mirage Definition at line 189 of file MirageComm.h. 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 |