INCF / MUSIC

MUSIC, the MUltiSimulation Coordinator
GNU General Public License v3.0
37 stars 37 forks source link

Converging jointstates to rate encoder #50

Closed Aamanen closed 6 years ago

Aamanen commented 6 years ago

I'm trying to read the positions of 2 joints from the topic /joint_states as known from http://wiki.ros.org/joint_state_publisher. These positions i want to feed to my neurons in NEST and they will respond by publishing a torque to topic /jointgroupeffort/command.

In this effort I'm having issues with converging from arrays generated by the publisher /jointstates into just 2 inputs to NEST. In doing so I have followed the example with the braitenberg vehicle where the "braitenberg3_converge_weights.dat"

braitenberg3_converge_weights.txt

converges 20 elements into 2 elements, by splitting the 20 elements into 1/20'th parts. Either I have misunderstood the procedure from the Braitenberg example, or I assume a wrong structure of data published in the /jointstates. This is my converging weight file fable_converge_weights2.txt Where i try to single out the position of the first joint and the position of the second joint. music file: fablenew5.txt

When running the simulations I get this error, which I don't receive when using the "braitenberg3_converge_weights.dat" in the same simulation.

martin@martin-X75VD:~/catkin_ws/src/ros-music-adapters/examples/braitenberg3/scripts$ mpirun -np 6 music fablenew5.music 
ContROSAdapter init 
[INFO] [2017.10.26 17:58:32 /opt/nest-2.12.0/nestkernel/rng_manager.cpp:226 @ Network::create_rngs_] : Creating default RNGs
ContContAdapter init 
LinearDecoderAdapter init 
RateEncoderAdapter init 
ROSContAdapter init 
[INFO] [2017.10.26 17:58:32 /opt/nest-2.12.0/nestkernel/rng_manager.cpp:221 @ Network::create_rngs_] : Deleting existing random number generators
[INFO] [2017.10.26 17:58:32 /opt/nest-2.12.0/nestkernel/rng_manager.cpp:226 @ Network::create_rngs_] : Creating default RNGs
[INFO] [2017.10.26 17:58:32 /opt/nest-2.12.0/nestkernel/rng_manager.cpp:272 @ Network::create_grng_] : Creating new default global RNG

              -- N E S T --

  Copyright (C) 2004 The NEST Initiative
  Version 2.12.0 Oct 16 2017 20:28:41

This program is provided AS IS and comes with
NO WARRANTY. See the file LICENSE for details.

Problems or suggestions?
  Visit http://www.nest-simulator.org

Type 'nest.help()' to find out more about NEST.

Oct 26 17:58:34 ModelManager::clear_models_ [Info]: 
    Models will be cleared and parameters reset.

Oct 26 17:58:34 Network::create_rngs_ [Info]: 
    Deleting existing random number generators

Oct 26 17:58:34 Network::create_rngs_ [Info]: 
    Creating default RNGs

Oct 26 17:58:34 Network::create_rngs_ [Info]: 
    Deleting existing random number generators

Oct 26 17:58:34 Network::create_rngs_ [Info]: 
    Creating default RNGs

Oct 26 17:58:34 Network::create_grng_ [Info]: 
    Creating new default global RNG

Oct 26 17:58:34 MusicEventHandler::publish_port() [Info]: 
    Mapping MUSIC output port 'out' with width=2.

Oct 26 17:58:34 NodeManager::prepare_nodes [Info]: 
    Preparing 8 nodes for simulation.

Oct 26 17:58:34 MusicEventHandler::publish_port() [Info]: 
    Mapping MUSIC input port 'in' with width=2 , acceptable latency=0 ms.

Oct 26 17:58:34 MUSICManager::enter_runtime [Info]: 
    Entering MUSIC runtime with tick = 1 ms

Oct 26 17:58:34 SimulationManager::resume [Info]: 
    Number of local nodes: 8
    Simulaton time (ms): 1000
    Number of OpenMP threads: 1
    Number of MPI processes: 1
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
[martin-X75VD:07505] *** Process received signal ***
[martin-X75VD:07505] Signal: Aborted (6)
[martin-X75VD:07505] Signal code:  (-6)
[martin-X75VD:07505] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x354b0)[0x7f983bb5f4b0]
[martin-X75VD:07505] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x38)[0x7f983bb5f428]
[martin-X75VD:07505] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x16a)[0x7f983bb6102a]
[martin-X75VD:07505] [ 3] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(_ZN9__gnu_cxx27__verbose_terminate_handlerEv+0x16d)[0x7f983c19984d]
[martin-X75VD:07505] [ 4] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d6b6)[0x7f983c1976b6]
[martin-X75VD:07505] [ 5] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d701)[0x7f983c197701]
[martin-X75VD:07505] [ 6] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8d919)[0x7f983c197919]
[martin-X75VD:07505] [ 7] /usr/lib/x86_64-linux-gnu/libstdc++.so.6(+0x8debc)[0x7f983c197ebc]
[martin-X75VD:07505] [ 8] /usr/local/lib/libmusic.so.1(_ZN5MUSIC4FIBO4growEi+0xa1)[0x7f983cc694a1]
[martin-X75VD:07505] [ 9] /usr/local/lib/libmusic.so.1(_ZN5MUSIC4FIBO6insertEv+0x27)[0x7f983cc695f7]
[martin-X75VD:07505] [10] /usr/local/lib/libmusic.so.1(_ZN5MUSIC17OutputRoutingData7processEdi+0x16)[0x7f983cc3de46]
[martin-X75VD:07505] [11] /usr/local/lib/libmusic.so.1(_ZN5MUSIC24IntervalProcessingRouterINS_17OutputRoutingDataENS_12IntervalTreeIiNS_8IntervalES1_EEE12processEventEdi+0xd4)[0x7f983cc392f4]
[martin-X75VD:07505] [12] /opt/music-adapters/libmusicadapter.so(_ZN12EventOutPort4sendEid+0xd)[0x7f983d0f3dad]
[martin-X75VD:07505] [13] music(_ZN11RateEncoder4tickEv+0x109)[0x408b99]
[martin-X75VD:07505] [14] /opt/music-adapters/libmusicadapter.so(_ZN7Adapter3runEb+0x88)[0x7f983d0f4f08]
[martin-X75VD:07505] [15] music(main+0x35)[0x408935]
[martin-X75VD:07505] [16] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f983bb4a830]
[martin-X75VD:07505] [17] music(_start+0x29)[0x4089b9]
[martin-X75VD:07505] *** End of error message ***
--------------------------------------------------------------------------
mpirun noticed that process rank 2 with PID 7505 on node martin-X75VD exited on signal 6 (Aborted).
weidel-p commented 6 years ago

I think you understood everything correctly, your procedure seems to be all right. Anyway, the error seems to happen in the RateEncoder and it's a bit mysterious.

I'm a bit suspicious about the received data from the joint_state_publisher. There could be an issue with the scaling of the data, as the RateEncoder expects input in the range between -1 and 1. I guess the positions of the joints can be between -pi and pi, right? If this is the case, could you please replace both 1 in fable_converge_weights2.txt with 0.318 (1 / pi) and let me know if that changes things?

Aamanen commented 6 years ago

Again that seemed to do the trick @weidel-p ! It was exactly as you say: the Joint_state_publisher was sending data exceeding the -1 to 1 limit and caused the crash. Replacing the weights in fable_converge_weights2 to 1/pi solved the problem. I'm once again very thankful for your help!

weidel-p commented 6 years ago

Great! I'm happy that I can help.

mdjurfeldt commented 6 years ago

Hi just a not-so-well-founded quick input from me:

Looking at the backtrace, I get the impression that this is due to memory corrution. This could be inside MUSIC. (I have recently committed fixes inserting missing virtual destructors---please update to master HEAD.) But it is more likely in the other code.

Philipp: Are there range checks in the adapters such that it is impossible to trash memory, given the wrong parameters?

Den 27 okt 2017 10:48 skrev "weidel-p" notifications@github.com:

I think you understood everything correctly, your procedure seems to be all right. Anyway, the error seems to happen in the RateEncoder and it's a bit mysterious.

I'm a bit suspicious about the received data from the joint_state_publisher. There could be an issue with the scaling of the data, as the RateEncoder expects input in the range between -1 and 1. I guess the positions of the joints can be between -pi and pi, right? If this is the case, could you please replace both 1 in fable_converge_weights2.txt with 0.318 (1 / pi) and let me know if that changes things?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/INCF/MUSIC/issues/50#issuecomment-339912589, or mute the thread https://github.com/notifications/unsubscribe-auth/ADcfCeI9nteun4gFRbqI1ufFvwl4ZhHcks5swZjxgaJpZM4QH2hw .