abr / neurorobotics-2020

Neurorobotics 2020
Other
15 stars 5 forks source link

Error running rover.py #10

Closed hayday100 closed 2 years ago

hayday100 commented 2 years ago

Traceback (most recent call last): File "rover.py", line 299, in weights_name=weights, File "rover.py", line 66, in demo input_scale=np.array([steer_scale, accel_scale]), File "/home/user/nengo-interfaces/nengo_interfaces/mujoco.py", line 87, in init self.model = mjp.load_model_from_path(self.xml_file) File "mujoco_py/cymj.pyx", line 132, in mujoco_py.cymj.load_model_from_path Exception: Failed to load XML file: rover.xml. mj_loadXML error: b"Error: sizes must be positive in object 'floor' (id = 0)\nObject name = floor, id = 0, line = 30, column = 9"

hayday100 commented 2 years ago

The problem above has a workaround to change the floor object size of x and y from zero to something positive. However, it runs into the following problem next:

`$ python rover.py Creating window glfw Creating window glfw MuJoCo session created Build finished in 0:00:00
Optimization finished in 0:00:00
Construction finished in 0:00:00
/home/user/nengo-loihi/venv/lib/python3.6/site-packages/nengo/node.py:63: UserWarning: 'Node.size_out' is being overwritten with 'Node.size_in' since 'Node.output=None' "'Node.size_out' is being overwritten with " ['LoihiBlock(<Ensemble "accel">[0:1024:1]): 100.0% compartments, 0.1% in-axons, 25.0% out-axons, 3.5% synapses', 'LoihiBlock(<Ensemble "accel">[1024:2048:1]): 100.0% compartments, 0.1% in-axons, 25.0% out-axons, 3.5% synapses', 'LoihiBlock(<Ensemble "accel">[2048:3072:1]): 100.0% compartments, 0.1% in-axons, 25.0% out-axons, 3.5% synapses', 'LoihiBlock(<Ensemble "accel">[3072:4096:1]): 100.0% compartments, 0.1% in-axons, 25.0% out-axons, 3.5% synapses', 'LoihiBlock(<Ensemble "steer">[0:1024:1]): 100.0% compartments, 0.3% in-axons, 25.0% out-axons, 10.5% synapses', 'LoihiBlock(<Ensemble "steer">[1024:2048:1]): 100.0% compartments, 0.3% in-axons, 25.0% out-axons, 10.5% synapses', 'LoihiBlock(<Ensemble "steer">[2048:3072:1]): 100.0% compartments, 0.3% in-axons, 25.0% out-axons, 10.5% synapses', 'LoihiBlock(<Ensemble "steer">[3072:4096:1]): 100.0% compartments, 0.3% in-axons, 25.0% out-axons, 10.5% synapses', 'LoihiBlock(<Ensemble "conv2d_1.0">[0:960:1]): 93.8% compartments, 53.7% in-axons, 93.8% out-axons, 74.3% synapses', 'LoihiBlock(<Ensemble "conv2d_1.0">[960:1920:1]): 93.8% compartments, 53.7% in-axons, 93.8% out-axons, 72.2% synapses', 'LoihiBlock(<Ensemble "dense.0">[0:50:1]): 4.9% compartments, 46.9% in-axons, 1.2% out-axons, 82.0% synapses', 'LoihiBlock(<Ensemble "dense.0">[50:100:1]): 4.9% compartments, 46.9% in-axons, 1.2% out-axons, 82.0% synapses', 'LoihiBlock(<Ensemble "dense.0">[100:150:1]): 4.9% compartments, 46.9% in-axons, 1.2% out-axons, 82.0% synapses', 'LoihiBlock(<Ensemble "dense.0">[150:200:1]): 4.9% compartments, 46.9% in-axons, 1.2% out-axons, 82.0% synapses', 'LoihiBlock(<Ensemble "dense_1.0">): 9.8% compartments, 4.9% in-axons, 4.9% out-axons, 17.1% synapses', 'LoihiBlock(<Connection from <Ensemble "accel"> to <Node (unlabeled) at 0x7fe5e417acf8> computing \'accel_function\'>): 0.2% compartments, 100.0% in-axons, 0.0% out-axons, 25.0% synapses', 'LoihiBlock(<Connection from <Ensemble "steer"> to <Node (unlabeled) at 0x7fe5e40b3320> computing \'\'>): 0.2% compartments, 100.0% in-axons, 0.0% out-axons, 25.0% synapses', 'LoihiBlock(<Connection from <Neurons of <Ensemble "dense_1.0">> to <Ensemble "steer">>): 5.9% compartments, 2.4% in-axons, 0.6% out-axons, 4.9% synapses', 'LoihiBlock(<Connection from <Neurons of <Ensemble "dense_1.0">> to <Ensemble "accel">>): 3.9% compartments, 2.4% in-axons, 0.4% out-axons, 3.7% synapses', 'Average (19 blocks): 54.1% compartments, 26.6% in-axons, 21.0% out-axons, 31.9% synapses'] Traceback (most recent call last): File "rover.py", line 317, in sim.run(sim_runtime) File "/home/user/nengo-loihi/venv/lib/python3.6/site-packages/nengo_loihi/simulator.py", line 349, in run self.run_steps(steps) File "/home/user/nengo-loihi/venv/lib/python3.6/site-packages/nengo_loihi/simulator.py", line 362, in run_steps self._runner.run_steps(steps) File "/home/user/nengo-loihi/venv/lib/python3.6/site-packages/nengo_loihi/simulator.py", line 549, in emu_bidirectional_with_host self.host.step() File "/home/user/nengo-loihi/venv/lib/python3.6/site-packages/nengo/simulator.py", line 418, in step step_fn() File "/home/user/nengo-loihi/venv/lib/python3.6/site-packages/nengo/builder/processes.py", line 123, in step_simprocess output[...] = step_f(args[0].item(), *args[1:]) File "/home/user/nengo-loihi/nengo-interfaces/nengo_interfaces/mujoco.py", line 210, in step self.exit = self.viewer.exit AttributeError: 'MjViewer' object has no attribute 'exit'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "rover.py", line 346, in direct[:, 0], "r--", alpha=0.5, lw=3, label="Ideal steering torque" IndexError: too many indices for array: array is 1-dimensional, but 2 were indexed `

studywolf commented 2 years ago

Hello @hayday100 !

I haven't had the chance to look over this issue yet, but I wanted to let you know that I'll be able to look into it this weekend, and you're not just sending messages off into a dark cyber void!

Just looking at this line, though,

AttributeError: 'MjViewer' object has no attribute 'exit'

which mujoco_py install are you using? I believe this may require this one https://github.com/studywolf/mujoco-py and I don't recall if that was well documented.

hayday100 commented 2 years ago

Hello @hayday100 !

I haven't had the chance to look over this issue yet, but I wanted to let you know that I'll be able to look into it this weekend, and you're not just sending messages off into a dark cyber void!

Just looking at this line, though,

AttributeError: 'MjViewer' object has no attribute 'exit'

which mujoco_py install are you using? I believe this may require this one https://github.com/studywolf/mujoco-py and I don't recall if that was well documented.

Hello @studywolf:

Good to hear from you!

That's exactly the problem. I installed the mujoco-py from openai github which wasn't compatible. Now the rover is working perfectly!

I also downloaded the h5 data file for the arm simulation. Could you give some insight into the following error?

python plot_full.py Traceback (most recent call last): File "plot_full.py", line 9, in plot_performance(ax) File "/home/user/neurorobotics-2020/arm_demo/plot_performance.py", line 22, in plot_performance save_location="%s/pd_no_weight/statistical_error_0" % (test_group), File "/home/user/abr_analyze/abr_analyze/data_handler.py", line 144, in load raise ValueError('The path %s does not exist'%(save_location)) ValueError: The path weighted_tests/pd_no_weight/statistical_error_0 does not exist

studywolf commented 2 years ago

Oh great, glad the first issue is resolved!

Hmmmm, sorry about that. @p3jawors could you double check the name of the keys in the h5 file?

hayday100 commented 2 years ago

Yes, it seems all keys/values are there:

>>> import h5py
>>> f = h5py.File('abr_neurorobotics2020_adaptation_data.h5', 'r')
>>> list(f.keys())
['weighted_tests']
>>> dset = f['weighted_tests']
>>> list(dset.keys())
['nengo_cpu1k', 'nengo_gpu1k', 'nengo_loihi1k', 'pd', 'pd_no_weight', 'pid']
>>> list(dset['pd_no_weight'].keys())
['proc_data', 'session000', 'session001', 'session002', 'session003', 'session004', 'statistical_error_0']
>>> list(dset['pd_no_weight']['statistical_error_0'].values())
[<HDF5 dataset "datestamp": shape (), type "|O">, <HDF5 dataset "lower_bound": shape (50,), type "<f8">, <HDF5 dataset "mean": shape (50,), type "<f8">, <HDF5 dataset "time_derivative": shape (), type "<i8">, <HDF5 dataset "timestamp": shape (), type "|O">, <HDF5 dataset "upper_bound": shape (50,), type "<f8">]
>>> 
p3jawors commented 2 years ago

Hi @hayday100 ,

Sorry for the delay in responding. I won't be able to test it out this week, but I believe the issue is with the import of DataHandler in the plotting script here. Instead of importing from abr_analyze there is a stripped down version of the data handler at the root of this repo. I suspect that if you change it to import that version it should work. Let me know if you still have issues and I'll dig into this as soon as I get a moment.

Cheers,

Pawel

hayday100 commented 2 years ago

That is indeed the problem. Just to document my changes. The beginning of plot_performance.py should be:

#from abr_analyze import DataHandler
import sys
sys.path.append("../")
from data_handler import DataHandler

Then I touched two files data/Nengo_gpu_GPU_power.log and figures/adaptive_arm_results.pdf. It works then.

Thanks!

studywolf commented 2 years ago

Ah excellent, glad it's working! Thanks for posting the steps taken, we'll update the README accordingly.

hayday100 commented 2 years ago

@studywolf Thanks! Just curios, is it possible to release the arm simulation code in addition to the results plot?

studywolf commented 2 years ago

oh, so this was run not with an arm simulation but with the actual Jaco2 arm. We used the https://github.com/abr/abr_jaco2 repo for interfacing. If you'd like to see an example of the arm simulation with adaptive control you can check out our examples in the ABR Control repo https://github.com/abr/abr_control/blob/main/docs/examples/Mujoco/force_osc_xyz_dynamics_adaptation.py

You'll need to have Mujoco and our repo installed, but everything you need to simulate adaptive control is there!