![]() |
RobWorkProject
23.9.11-
|
Implementation of the Wolfram Symbolic Transfer Protocol (WSTP) to allow communication with Mathematica. More...
Classes | |
class | Mathematica |
Implementation of the Wolfram Symbolic Transfer Protocol (WSTP) to allow communication with Mathematica. More... | |
struct | Mathematica::Link |
Representation of a link. More... | |
class | Mathematica::Expression |
A representation of a Mathematica expression. More... | |
class | Mathematica::String |
A string primitive. More... | |
class | Mathematica::Integer |
An integer primitive. More... | |
class | Mathematica::Real |
A real primitive. More... | |
class | Mathematica::Symbol |
A symbol primitive. More... | |
class | Mathematica::FunctionBase |
A base interface for function expressions. More... | |
class | Mathematica::Function |
A user definable function expression. More... | |
class | Mathematica::Array< T > |
An Array primitive. More... | |
class | Mathematica::AutoExpression |
Convenience class for automatic Expression deduction. More... | |
class | Mathematica::Packet |
A Packet expression. More... | |
Namespaces | |
rwlibs | |
Extension libraries for RobWork. | |
rwlibs::mathematica | |
Implementation of the Wolfram Symbolic Transfer Protocol (WSTP) to allow communication with Mathematica. | |
Functions | |
std::ostream & | operator<< (std::ostream &out, const Mathematica::Expression &expression) |
Print a Mathematica expression to an output stream. More... | |
Implementation of the Wolfram Symbolic Transfer Protocol (WSTP) to allow communication with Mathematica.
Example of basic usage:
Construction of a Mathematica environment, m, makes it possible to create WSTP links (Mathematica::Link). Please note that the Mathematica object automatically closes all links at destruction. WSTP links can be used for different types of interprocess communication with Wolfram Symbolic expressions. In this example we launch and connect to a kernel.
The first expression (the In[1]:= prompt) is received from the kernel with the stream operator *l >> result. We simply ignore this value, and send the first command to be evaluated with the stream operator. The result is then retrieved and printed:
ReturnPacket[ List[ List[ Rule[x, 15], Rule[y, 12]], List[ Rule[x, 41], Rule[y, 10]], List[ Rule[x, 57], Rule[y, 6]]]]
Streaming of a string to the link will implicitly create a ToExpression expression and wrap it in an EvaluatePacket. The kernel will evaluate the expression in the packet and send back a ReturnPacket with the result (as an expression). Many different types of packets can be sent and received on the link (see Mathematica::PacketType). It is up to the user to deal with the different packet types, and to parse the results received.