Skip to content

Commit

Permalink
Merge branch 'v2'
Browse files Browse the repository at this point in the history
  • Loading branch information
Guvalif committed Oct 20, 2016
2 parents 94be0f6 + f010e22 commit 45bed19
Show file tree
Hide file tree
Showing 16 changed files with 299 additions and 143 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ A communication tool between HTTP and Serial for PLEN series robots.

1. Download latest version of the application from [here](https://github.com/plenprojectcompany/plen-ControlServer/releases).
2. Unzip the downloaded file.
3. Run the `ControLServer.exe` or `ControlServer.app`.
3. Run the `ControlServer.exe` or `ControlServer.app`.
- If you are an OSX user, you need to run the application by following steps.
- Click on the application's icon with `ctrl` key.
- Choose `open` from menu items. (Using this method, you can turn off security alert temporary.)
4. Connect your PLEN and a laptop using USB type micro B cable.
5. Open the `PLEN_Utils.url`.
5. Start up any application to communicate with PLEN series robots. (s.a. [Motion Editor](http://plen.jp/playground/motion-editor/))

If you would like to use the application as a tuning up tool, Please [see also...](http://plen.jp/playground/wiki/tutorials/plen2/tune)

Expand Down
15 changes: 8 additions & 7 deletions control_server/config.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"port" : 17264,
"driver" : {
"name" : "usb",
"options" : {
"compiler" : {
"path" : "C:/workdir/app/Arduino/arduino.exe"
}
"port": 17264,
"driver": {
"name": "usb",
"options": {
"compiler": {
"path": "C:/workdir/app/Arduino/arduino.exe"
},
"verify": true
}
}
}
4 changes: 4 additions & 0 deletions control_server/drivers/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def stop(self):
def install(self, motion):
pass

@abstractmethod
def resetJointSettings(self):
pass

@abstractmethod
def getMotion(self, slot):
pass
Expand Down
3 changes: 3 additions & 0 deletions control_server/drivers/null/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def stop(self):
def install(self, motion):
return True

def resetJointSettings(self):
return True

def getMotion(self, slot):
return {}

Expand Down
25 changes: 25 additions & 0 deletions control_server/drivers/usb/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,31 @@ def install(self, motion):
return True


def resetJointSettings(self):
if self._serial is None:
_LOGGER.error('Serial connection is disabled!')

return False

try:
self._serial.write(
self._PROTOCOL.setJointSettings()
+ self._PROTOCOL.homePosition()
)

except (
serial.serialutil.SerialException,
serial.serialutil.SerialTimeoutException
):
_LOGGER.error('USB cable is disconnected!')

self.disconnect()

return False

return True


def getMotion(self, slot):
if self._serial is None:
_LOGGER.error('Serial connection is disabled!')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
@brief Provide empty motion's definition.
'''

MOTION = {
EMPTY_MOTION = {
'codes': [],
'frames': [
{
Expand Down
8 changes: 4 additions & 4 deletions control_server/router/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@

import logging
from bottle import (Bottle, request, response, abort, template, static_file)
from empty_motion import MOTION
from models.empty_motion import EMPTY_MOTION


# Create module level instances.
# ==============================================================================
_LOGGER = logging.getLogger('plen-ControlServer').getChild(__name__)

_empty_motion = MOTION
_empty_motion = EMPTY_MOTION
_driver = None

router = Bottle()
Expand Down Expand Up @@ -106,7 +106,7 @@ def cmdstream():
while True:
try:
messages = wsock.receive().split('/')
result = getattr(_driver, messages[0])(*messages[1:])
result = getattr(_driver, messages[0])(*messages[1:]) if (len(messages) == 1) else getattr(_driver, messages[0])()

wsock.send(str(result))

Expand Down Expand Up @@ -257,7 +257,7 @@ def metadata_get():
'resource': 'metadata',
'data': {
'api-version': 2,
'require-firmware': '1.1.0~'
'required-firmware': '1.4.1~'
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@ class ConnectButtonController
"PLENControlServerService"
];

constructor(public server: PLENControlServerService)
constructor(private _server: PLENControlServerService)
{
// noop.
}

getServerStatus(): string
{
if (this.server.getStatus() === SERVER_STATE.CONNECTED)
if (this._server.getStatus() === SERVER_STATE.CONNECTED)
{
return "Connected!";
}

if (this.server.getStatus() === SERVER_STATE.DISCONNECTED)
if (this._server.getStatus() === SERVER_STATE.DISCONNECTED)
{
return "Disconnected!";
}
Expand All @@ -28,6 +28,6 @@ class ConnectButtonController

onClick(): void
{
this.server.connect();
this._server.connect(() => { this._server.checkVersionOfPLEN() });
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="form-group">
<div class="btn-group btn-group-justified" role="group">
<a class="btn btn-default disabled" role="presentation">{{ $ctrl.getServerStatus(); }}</a>
<a class="btn btn-success" role="button" ng-click="$ctrl.onClick()">Connect</a>
<a class="btn btn-primary" role="button" ng-click="$ctrl.onClick()">Connect</a>
</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,49 @@
class SetterButtonsController
{
static $inject = [
"$window",
"PLENControlServerService",
"SharedJointSettingsService"
];

constructor(
public ctrl_server_service: PLENControlServerService,
public joint_settings: JointSettingsModel
private _$window: ng.IWindowService,
private _ctrl_server_service: PLENControlServerService,
private _joint_settings: JointSettingsModel
)
{
// noop.
}

onClickMax(): void
{
this.ctrl_server_service.setMax(
this.joint_settings.joint_handle,
this.joint_settings.getValue()
this._ctrl_server_service.setMax(
this._joint_settings.joint_handle,
this._joint_settings.getValue()
);
}

onClickHome(): void
{
this.ctrl_server_service.setHome(
this.joint_settings.joint_handle,
this.joint_settings.getValue()
this._ctrl_server_service.setHome(
this._joint_settings.joint_handle,
this._joint_settings.getValue()
);
}

onClickMin(): void
{
this.ctrl_server_service.setMin(
this.joint_settings.joint_handle,
this.joint_settings.getValue()
this._ctrl_server_service.setMin(
this._joint_settings.joint_handle,
this._joint_settings.getValue()
);
}

onClickReset(): void
{
this.joint_settings.setValue(0);
this.ctrl_server_service.applyNative(this.joint_settings.joint_handle, 0);
if (this._$window.confirm('Are you sure you want to reset the all joint settings?'))
{
this._ctrl_server_service.resetJointSettings();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="form-group">
<div class="btn-group btn-group-justified" role="group">
<a class="btn btn-default" role="button" ng-click="$ctrl.onClickHome()">Home</a>
<a class="btn btn-primary" role="button" ng-click="$ctrl.onClickReset()">Reset</a>
<a class="btn btn-warning" role="button" ng-click="$ctrl.onClickReset()">Reset All</a>
</div>
</div>
Loading

0 comments on commit 45bed19

Please sign in to comment.