Socket is not connected Pepper - pepper

I use pythonsdk and naoqi for programming my pepper robot. i created a session and call the main by it is follows:
try
session = qi.Session()
session.connect("tcp://#.#.#.#:9559")
except RuntimeError:
print ("Cannot connect to robot ")
main(session)
each run of my program may take about 2 hourse. Actually it is a toutrial based interaction which is a loop of two phase: robot speech and playing a video clip on pepper's tablet, then a new topic and new video clip and so on.
but after a while i got these errors:
RuntimeError: Session not connected.
RuntimeError: Socket is not connected
so what these errors mean? and how can i overcome them? Thanks in advance

You should make sure your session remains alive, by using it from the scope it was created:
session = qi.Session()
session.connect("tcp://#.#.#.#:9559")
main(session)

Related

Connect to multiple queue managers in different servers

I am trying to connect a C++ application (using MQCONNX) based on a PaaS IBM MQ client to two different queue managers, each one based on a different server (one in a PaaS server and the other one in a Unix server). Unfortunately I am not able to do it as I am getting a message when I try to connect to the second server saying that it is not possible as it is connected to the first queue manager. I am using two different MQHCONN connections, one for each queue manager, but the problem is still there.
I have taken a look into this link, but I still have some doubts, as for example, from which server should I copy the CCDT to the client?
https://www.ibm.com/support/pages/connecting-mq-clients-multiple-queue-managers-client-channel-definition-table-ccdt
Any help would be much appreciated, or even a quick sample of how to use CCDT, as right now I am completely stuck.
Many thanks in advance for any help.
Assuming Queue Manager 1 is called MQG1 and Queue Manager 2 is called MQG2 and these can be found using connection names of machine1.com(1701) and machine2.com(1702) respectively, and using channel names MQG1.SVRCONN and MQG2.SVRCONN respectively, you can create your CCDT, on your client application machine, thus:-
runmqsc -n
issue these commands into runmqsc:-
DEFINE CHANNEL(MQG1.SVRCONN) CHLTYPE(CLNTCONN) CONNAME('machine1.com(1701)') QMNAME(MQG1)
DEFINE CHANNEL(MQG2.SVRCONN) CHLTYPE(CLNTCONN) CONNAME('machine2.com(1702)') QMNAME(MQG2)
Then you can code your 2 x MQCONN (or MQCONNX if you need to specify any additional things on the connection) thus:-
#include <cmqc.h> /* Includes for MQI constants */
#include <cmqstrc.h> /* Convert MQRC into string */
MQHCONN hConn1 = MQHC_UNUSABLE_HCONN;
MQHCONN hConn2 = MQHC_UNUSABLE_HCONN;
MQCHAR QMName1[MQ_Q_MGR_NAME_LENGTH] = "MQG1";
MQCHAR QMName2[MQ_Q_MGR_NAME_LENGTH] = "MQG2";
MQLONG CompCode, Reason;
MQCONN(QMName1,
&hConn1,
&CompCode,
&Reason);
if (CompCode)
{
printf("MQCONN to %s failed with reason code %s (%d)\n", QMName1, MQRC_STR(Reason), Reason);
}
MQCONN(QMName2,
&hConn2,
&CompCode,
&Reason);
if (CompCode)
{
printf("MQCONN to %s failed with reason code %s (%d)\n", QMName2, MQRC_STR(Reason), Reason);
}
Take care with how you are linking your program. If you try to make two local connections, you will get a return code of MQRC_ANOTHER_Q_MGR_CONNECTED. Ensure you either link with the client library, set connection option MQCNO_CLIENT (which means you must use MQCONNX) or set the environment variable MQ_CONNECT_TYPE=CLIENT.
You might find the following blog post useful additional reading:-
IBM MQ Little Gem #30: MQ_CONNECT_TYPE

Live555MediaServer restarts the stream at every new connection. Why setting "reuseSource" to true is not working as expected?

Live555MediaServer can be used to stream video files as rtsp streams. I have 2 clients (vlc) that connect to the server, A and B. I want to see the exact video stream in both the clients. Here is the problem: I connect A and after 10 seconds I connect B. When B is connected the video that I see starts over from the beginning, while A keeps streaming as it was.
I would like the 2 concurrent streams to be synchronized.
The live555 doc says that setting reuseFirstSource to True should work. So I tried to set reuseSource to true at DynamicRTSSPServer:121 but it didn't work. When I connect to the server using client B the video restarts from the beginning.
Boolean const reuseSource = True;
I expect to see the 2 concurrent streams synchronized even if one starts with a delay with respect to the other one.
I finally found a workaround and why there was this 'bug'.
Quick answer: set if condition at line 67 to false, i.e.
if (smsExists && isFirstLookupInSession) {
becomes
if (false) {
Explaination: Every time a new session is starting, the isFirstLookupInSession variable is set to true and the session is removed and recreated.
I wrote to the support of live555 and Finlayson told me and I quote
“LIVE555 Media Server” code was always intended to work this way, and was intended to be a ‘stand-alone appliance’ that does not have its code modified (e.g., by changing the value of “reuseFirstSource”).
Thus the only solution for creating a RTSP server through Live555 is to create your own server starting from the testProgs examples.
The workaround proposed here could generate unwanted behaviors, but for a simple rtsp server with multiple streams it's fine.

Poloniex & websockets

===SIMPLE & SHORT===
Does anybody have working application that talks with Poloniex through WAMP in these days (January, 2018)?
===MORE SPECIFIC===
I used several info sources to make it work using combo: autobahn-cpp & C++. Windows 10 OS.
I was able to connect to wss://api.poloniex.com, realm1. Plus I was able to subscribe and get subscription ID. But I never got any events even when everything established.
===RESEARCH===
During research in the web I saw a lot of controversial information:
1. Claims, that wss://api2.poloniex.com should be used, and channels names are actually numbers - How to connect to poloniex.com websocket api using a python library
2. This answer gave me base code, but I am getting anything more than just connections, also by following this answer - wss://api.poloniex.com is correct address - Connecting to Poloniex Push-API
3. I saw post (sorry, lost the link), there were comments made that websockets implementation are basically broken on poloniex. They were posted 6 months ago.
===SPECS===
1. Windows 10
2. Autobahn-Cpp
3. wss://api.poloniex.com:443 ; realm1
4. Different subscriptions: ticker, BTC_ETH, 148, 1002, etc..
5. Source code I got from here
===WILL HELP AS WELL===
Is there any way to get all valid subscriptions or, probably, those, that have more than 0 subscribers? I mean, does WAMP have a way to do that?
Is there any known issues with Autobahn-Cpp and poloniex combo?
Is there any simpler way to test WAMP elsewhere to make sure Autobahn isn't a problem? Like any other well documented & supported online projects that accept WAMP websocket communication?
I can receive the correct tick order book data from wss://api2.poloniex.com use python3
but sometime The channel 1002 may stop sending the new tick info.
wss://api.poloniex.com:443 ; realm1
This may be the issue as I've been using api2 and here is the code that works, and has been working for the past 2 quarters non-stop. Its in python, but should be easy enough to port to C++.
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import websocket
import json
def on_error(ws, error):
print(error)
def on_close(ws):
print("### closed ###")
connection.close()
def on_open(ws):
print("ONOPEN")
ws.send(json.dumps({'command':'subscribe','channel':'BTC_ETH'}))
def on_message(ws, message):
message = json.loads(message)
print(message)
websocket.enableTrace(True)
ws = websocket.WebSocketApp("wss://api2.poloniex.com/",
on_message = on_message,
on_error = on_error,
on_close = on_close)
ws.on_open = on_open
ws.run_forever()
the code is pretty much self-explanatory (You can check all channels/pairs on Poloniex API website), just save it and run in terminal
python3 fileName.py
should provide You with BTCETH raw stream of orders and trades on console output.
Playing with the message/subscriptions You can then do as You please with it.
It seems that websockets in Poloniex are unstable. Therefore I can stop my attempts make Autobahn-Cpp work with it at least by now and move on.

Pyserial/Eye-tracker: Reading from serial port whilst displaying stimuli

I am using Pyserial (+Python 2.7) to read in eye-tracking coordinates taken from an eye-tracker (CRS Live-Track set as serial port). Using the code below I am able to successfully start the tracker, read/save a line of coordinates, stop the tracker, and close. My problem is I need to continuously read in the coordinates whilst carrying out other tasks such as stimuli display. As it stands, I can't do anything whilst I'm reading in data ('trial1 = ser.readline'). I have to wait until I've read in the data before I continue. Is there a way to read in the data from the serial port continuously whilst I am displaying stimuli/collecting responses etc.?
I need to turn the tracker on, collect the data for the duration of the trial, and then tracker off.
import serial, time
ser = serial.Serial(
port='COM3',
baudrate=9600,
parity=serial.PARITY_ODD,
stopbits=serial.STOPBITS_TWO,
bytesize=serial.SEVENBITS,
)
x = ser.is_open #check port is open
if x:
print "port is open"
print "port name is: %s" %(ser.name) #check which port
ser.flushInput()
ser.flushOutput()
running = True
while running:
ser.write('$Raw\r') #start eye-tracker
trial1 = ser.readline() #read a line
###i need to do stuff here###
ser.write('$Stop\r') #stop eye-tracker
running = False
ser.flushInput()
ser.flushOutput()
print trial1 #print coordinates output
ser.close()
Cheers,
Steve
ioHub by Sol Simpson provides asynchronous device monitoring from within PsychoPy. i.e it operates on an entirely separate process so you don't have to pause while monitoring the port in the main PsychoPy thread.
Serial port documentation in ioHub seems scarce but there is a demo here: https://github.com/psychopy/psychopy/blob/master/psychopy/demos/coder/iohub/serial/customparser.py
Another option would be to try threads. You could put your eye tracker in one thread and the rest of your code in another. There is a stack overflow answer about multithreading (not using psychopy and eye trackers) from 2010. If you scroll down you will see that someone links to a blog post about an updated approach that they think is easier.

unable to load achievement screen in game center

I want to load achievement screen in my gamecenter. The GKAchievement completeHandler is returing blank array of achievement and so Error is coming
"Error Domain=GKErrorDomain Code=3 "The requested operation could not be completed due to an error communicating with the server." UserInfo=0xae232f0 {NSUnderlyingError=0xae2f9b0 "The operation couldn’t be completed. status = 5044, Game does not support achievements", NSLocalizedDescription=The requested operation could not be completed due to an error communicating with the server.}
And achievement screen is showing "unable to load achievement". What is cause of this error?
I had this exact same issue even after enabling the application in iTunesConnect. My problem was that I was authenticating the user in the AppDidFinishLaunching callback. Try moving this call forward to after the app launches and it should clear it up if you are having the same issue that I did.