Game Development Community

Socket Programming for External Servers

by Caglar Arslan · in Technical Issues · 04/21/2007 (12:54 pm) · 5 replies

I am planning to integrate MATLAB to TGE Server via networking. My MATLAB server is ready. All I need is console commands which can send/receive specific data by using a specified IP address and port number (socket).
My question is that; are there any commands like

openSocket(socketName,IP Address, Port Number)
send(socketName, data)
receiveData(socketName, data)

in TGE v1.5?

#1
04/26/2007 (8:03 am)
Self response:

/* MATLAB Interface Script
*/

new TCPObject(MATLABSocket);
MATLABSocket.serverAddress = "127.0.0.1";


// Function for connecting to the MATLAB Server
function connectToMATLABServer(%port) {
MATLABSocket.connect(MATLABSocket.serverAddress @":"@ %port);
}

function disconnectFromMATLABServer() {
MATLABSocket.disconnect();
}

function sendToMATLABServer(%value) {
MATLABSocket.send(%value);
MATLABSocket.send("\r\n");
}

function MATLABSocket::onConnected(%this) {
// Output red text to show we connected
echo("Connected to MATLAB Computing Server");
// Send the request for the file to the server
%this.send("12345");
%this.send("\r\n");
}

// Procedures on disconnection (NOT Necessary)
function MATLABSocket::onDisconnect(%this) {
// Output red text to show we connected
echo("MATLAB Server's connection is terminated");
}

function MATLABSocket::onReceive(%this) {
echo("Received Packet:"@ %this.buffer);
}

function MATLABSocket::onConnectFailed(%this)
{
error("Connection Failed: " @ %this.serverAddress);
}

function MATLABSocket::onLine(%this, %line)
{
echo(%line);
}
#2
04/26/2007 (5:53 pm)
:)

Whats the use of the MATLAB server?

Thought MATLAB was a tool for doing calculations, etc ... never heard of MATLAB server ... makes me wonder ... kind of curious ;)
#3
04/27/2007 (4:16 am)
Well... hmm. let me explain.
Matlab is a technical computing platform in which there are lots of provided mathematical libraries for rapid prototyping. By openning a MATLAB server you can accept commands from external applications and respond to them.
As a part of my graduate course in Bilkent (Robot Motion and Control), me and my partner will try to implement a 3D path-planning algorithm by using MATLAB for computations and Torque for visualization.
For instance assume that a butterfly-bot has to generate a collision free path from a starting configuration (in terms of X-Y-Z coordinates) to a goal configuration (again in terms of X-Y-Z, naturally). Note that, between these configurations, there will be dynamic obstacles (like: flying eagles) or static obstacles (like: hanging balloons).
So, David. What do you say? :) I mean I need your comments.
#4
04/27/2007 (4:32 am)
That is a sweet idea, and should be pretty simple to implement on the Torque side of things.
#5
04/27/2007 (4:52 am)
Recently, I got some questions.
First of all,
Is there a way to extract the collision X-Y-Z coordinate values when a moving object (bot) hits an obstacle?
One solution could be to use getTransform() and onCollision(%this, %obj, %col) methods. But by using these methods how precise can I obtain the exact collision coordinate values?
My main discussion is; "Is there a specialized method or a more detailed onCollision method built in TGE?
Secondly,
Is it possible to use onCollision method which is indicated on the following link?
http://tdn.garagegames.com/wiki/Determining_collision_source_destination
Thirdly,
is there a way to extract the polygonal details of obstacles (static shapes) in Torque?