Git Product home page Git Product logo

Comments (12)

mbanerj avatar mbanerj commented on September 24, 2024

Well, I figured out part of it.

image

The thread that fails to quit is something called "XML-RPC Weblistener". Can you recommend a good way to close this thread in the context of ROSBaseApplication?

from iiwa_stack.

SalvoVirga avatar SalvoVirga commented on September 24, 2024

Really good point, we really hate that ROSSmartServo is not cleaned properly and we tried to make sure everything is disposed correctly, but still something is not.

I recently noticed that ROSSmartServo closes properly if a roscore is still running on the Linux side - at least for me on 16.04. Else, there are those 15 seconds to wait and the incredible annoying "PermGen Space" error after too many runs/syncs.

Thanks for points us out to the possible problem! That thread is part of what ROSJava builds, so we might need to have a look in there directly (we provide all the needed jars but one can also use the source code from the repo to check what is going on).

We are under deadline, so we won't be able to work on this for the next 2-3 weeks.

from iiwa_stack.

mbanerj avatar mbanerj commented on September 24, 2024

Thanks for the response. I'll look at the jars' source code and see if I can find the chain leading to XML-RPC Weblistener in the meantime and let you know if I find anything.

Also just FYI, I'm on Indigo, and the task apparently fails to terminate regardless of connection to roscore.

from iiwa_stack.

mbanerj avatar mbanerj commented on September 24, 2024

So a quick update, I recently started ramping back up on my iiwa project and was going to follow up on this issue. I see this update on the rosjava repository that seems to involve some kind of fix to publishers and subscribers on node shutdown. Do you think this would solve the issue we're talking about in this thread?

from iiwa_stack.

SalvoVirga avatar SalvoVirga commented on September 24, 2024

Definitely. I was already following that fix and I have in mind to try the new version since weeks, but still didn't have the time. jars can be found already here, there are also some others that might be worthing upgrading.

from iiwa_stack.

mbanerj avatar mbanerj commented on September 24, 2024

One thing you're probably going to run into when you try it - the rosjava source was compiled in a later version of Java (1.8 I think) while Sunrise uses v1.6 for runtime. So the project doesn't want to synchronize if you drop in the .jar files from the repo you linked.

I tried dropping the source files in my ros workspace (like your guide for the messaging) but, after a day of categorically failing to get it to compile properly, have given up. I don't have the expertise to really go any further :( (unless of course you have any suggestions).

from iiwa_stack.

SalvoVirga avatar SalvoVirga commented on September 24, 2024

Oh, I'm sorry you had to fight with this. I actually have a solution, since I had to generate jars in the past. Java 7 should be ok too. The following works for ROS Kinetic and 16.04, which I suggest you to use anyway.

Install Java 7 (need to add a ppa for 16.04)

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt update
sudo apt install openjdk-7-jdk

Switch the default Java to use to Java 7

sudo update-alternatives --config java

Install the necessary packages to build rosjava_core

sudo apt install ros-kinetic-genjava
sudo apt install ros-kinetic-rosjava-test-msgs

Build the workspace where rosjava_core was cloned with catkin_make

catkin build would not generate the jars.

from iiwa_stack.

SalvoVirga avatar SalvoVirga commented on September 24, 2024

I am quite overwhelmed with others duties until the end of the month, else I would give it a try myself.

from iiwa_stack.

mbanerj avatar mbanerj commented on September 24, 2024

No worries, everyone's busy and the thread termination issue isn't because of anything in iiwa_stack anyway.

Your steps are much appreciated! I will try them out tomorrow. I'm assuming that after switching the version to 1.7 for compile, I need to go into my Sunrise project > Settings > Java > Compile and change the compatibility to 1.7 as well? I think that should be the only other thing to change, but I will try it out and let you know if it works.

from iiwa_stack.

mbanerj avatar mbanerj commented on September 24, 2024

Unfortunately, this doesn't seem to jibe well with Sunrise. The controller is running Java 1.6, and produces "unsupported major.minor 51.0" as the getLogger output even if you manage to get the project to synchronize properly :(

UPDATE! I forced compilation in Java 1.6 from catkin and managed to synchronize it successfully to the Sunrise controller. I have started ROSSmartServo and stopped the application after seeing "Starting the ROS control loop:" about 10 times now without once seeing the improper termination problem. Are there any other conditions that you know of where the issue is likely to occur that I can test out? So far this seems promising! (!!!!!)

UPDATE 2: I may have spoken too soon. I went back and read your comment about proper shutdown when roscore is running. Upon trying to start and terminate ROSSmartServo without roscore, it throws an InterruptedExceptionError and still persists with the active threads. :(

from iiwa_stack.

mbanerj avatar mbanerj commented on September 24, 2024

So I've been messing around with multithreading for my custom additions to iiwa_stack in the last couple of weeks and have learned enough to identify something. This section in ROSBaseApplication.java causes a blocking wait:

try {
	getLogger().info("Waiting for ROS Master to connect... ");
	configuration.waitForInitialization();  <<<<<<<<<<<<<<<<------
	getLogger().info("ROS Master is connected!");
} catch (InterruptedException e1) {
	e1.printStackTrace();
	return;
}

waitForInitialization() theoretically throws an InterruptedException, but I see no way to interrupt the thread programatically. nodeMainExecutor calls .execute, which I believe allows little control over the task itself. I am new to multithreading though, so I fully acknowledge that I may be missing something.

Anyway, this seems to be why it closes properly with roscore running and improperly without roscore. If the iiwaConfiguration can't acquire the connection, the thread just sits in an blocking wait indefinitely while waiting to acquire the semaphore permit from iiwaConfiguration.

from iiwa_stack.

SalvoVirga avatar SalvoVirga commented on September 24, 2024

@mbanerj if you have time, you could check the branch this branch or 6be0c82. From my experience this completely solves the problem.

from iiwa_stack.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.