OpenRoberta / robertalab-ev3dev

roberta lab connector for ev3dev
Apache License 2.0
17 stars 14 forks source link

rename robots to establish BT connections #43

Closed afgym-baeu closed 7 years ago

afgym-baeu commented 7 years ago

I'd like to have one EV3 communicate with multiple other ones. The fundamental problem seems to me that there is no way to rename the devices in ev3dev without loosing the ability to connect to the brick in open-roberta lab.

I changed the hostname of each brick to different values (e.g. "robot01", "robot02", ...) by calling sudo ev3dev-config (tried sudo hostname robotXY, too) via ssh and restarted them. I thought the hostname is the "robot name" I need to establish the BT connection. spectacle k31192

But if the hostname is not "ev3dev" the lab does not connect to the robot, because the hostname string seems to be the identifier for the type of robot. nepo-differentrobot

Is there any way to set the name for the BT connection without changing the hostname?

ensonic commented 7 years ago

I am using /proc/version to identify the os-version right now, see: https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/lab.py#L99-L100 I don't have access to an ev3 right now. Could you please check if that changes when you rename the robot? On my laptop this does not happen.

afgym-baeu commented 7 years ago

I used a clean image and did a cat /proc/version then I renamed the robot to "robot01", performed a reboot an looked at the /proc/version again. The string is exacly the same: Linux version 4.4.47-19-ev3dev-ev3 (david@freyr) (gcc version 4.5.2 (Sourcery G++ Lite 2011.03-42) ) #1 PREEMPT Wed Feb 8 14:15:28 CST 2017

I do not think it is the firmwareversion that does not match. In https://github.com/OpenRoberta/robertalab/blob/master/OpenRobertaRobot/src/main/java/de/fhg/iais/roberta/robotCommunication/RobotCommunicator.java#L105 there are three conditions to be checked and the following string for the log file contains state.getRobot() and nothing about the firmware version ( state.getFirmwareName() ) . But as stated in Issue#42 https://github.com/OpenRoberta/robertalab-ev3dev/issues/42 the state.getRobot() differs from robot when renaming the brick.

afgym-baeu commented 7 years ago

hard coding the brickname in https://github.com/OpenRoberta/robertalab-ev3dev/blob/develop/roberta/lab.py#L351 to self.params['brickname'] = 'ev3dev' did it for me. Now it is possible to connect the lab and the robot. A simple BT scan shows the device by its hostname robot01. Didn't have time enough to send messages from one robot to the other one; will try tomorrow.

afgym-baeu commented 7 years ago

I can't test it because lab.open-roberta.org (with server version 2.2.5) throws a server error (and erases the whole program if you did not save it) when starting a program that uses any kind of message block. This although happens with a clean image so I do not think that issue is related to the renaming problem - I will open a new issue for that.

Does anyone use messages on ev3dev robots?

ensonic commented 7 years ago

Sound like the intention of the server code is not clear:

 } else if ( !(state.getRobot().equals(robot)
            || state.getRobotName().toLowerCase().equals(robot)
            || (state.getRobot() + state.getFirmwareName()).equals(robot)) ) {
            LOG.info("token " + token + " belongs to a robot of type " + state.getRobot() + ", client is set to " + robot);
            return Key.TOKEN_SET_ERROR_WRONG_ROBOTTYPE;

As we see in https://github.com/OpenRoberta/robertalab-ev3dev/issues/42#issuecomment-306750114 state.getRobot() == "ev3" and robot == "ev3dev". We should definitely not check the robotname.

ensonic commented 7 years ago

I have a fix in the upstream bug that has now been submitted. We'll have it soon up for testing on the staging instance.

ensonic commented 7 years ago

This should work now with the new server release. Let me know if you still have troubles with this.

ensonic commented 7 years ago

What did you use to change the name of the ev3 in the end. I don't have ev3dev-config and changing the hostname won't survive the reboot.

afgym-baeu commented 7 years ago

ev3dev-config is part of ev3dev since 2015 in /usr/sbin/ on the brick and can easily be used by calling sudo ev3dev-config if you are working on the brick using ssh. It provides a simple to use ASCII-based user interface to set the user password, update ev3dev/debian, change the hostname and enable/disable system services like openrobertalab. Changing hostname and system services can be found in the "Advanced Options" menu. Permanently enable the openrobertalab system service did not work for me for the first time, hece I used systemctl ever since, but changing the hostname works fine. This ev3dev github issue states using sudo hostnamectl set-hostname myBricksName is possible, too. A reboot is recommended the one or the other way.