Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mapbytes makes no sense although lidar scan is very reasonable #72

Open
Avi-avidan opened this issue Apr 11, 2020 · 10 comments
Open

mapbytes makes no sense although lidar scan is very reasonable #72

Avi-avidan opened this issue Apr 11, 2020 · 10 comments

Comments

@Avi-avidan
Copy link

hi,
I am getting a nice scan from my Slamtec RPLIDAR A1 (see image)
Screen Shot 2020-04-10 at 14 15 03

LIDAR_DEVICE = '/dev/ttyUSB0'

dists[:10] = [-0.0, -0.0, -0.0, -640.6713808877225, -616.3971794359838, -605.3760240984459, -588.6830172771465, -573.8061655912974, -584.4876481055396, -581.9273308674532]

angles[:10] = [-0.0, -0.0, -0.0, -109.72776180811681, -97.11084997755711, -89.79905036668178, -79.29883460350986, -69.50168580266731, -64.17311907687618, -59.87972603044943]

I am initializing objects as follows -
LaserModel = RPLidar
slam = RMHC_SLAM(LaserModel(), MAP_SIZE_PIXELS, MAP_SIZE_METERS, max_search_iter=5)
viz = MapVisualizer(MAP_SIZE_PIXELS, MAP_SIZE_METERS, 'SLAM')
mapbytes = bytearray(MAP_SIZE_PIXELS * MAP_SIZE_PIXELS)

running this simple loop to update my map -
for i in range(5):
time.sleep(0.1)
scan_dict = simple_express_scan(ret_points=NUM_POINTS)
dists ,angles = get_raw_data(scan_dict, ang_off=4)
time.sleep(0.1)
slam.update(dists, scan_angles_degrees=angles)
time.sleep(0.1)
x, y, theta = slam.getpos()
print(x, y, theta)
slam.getmap(mapbytes)

print(x, y, theta) always outputs: 5000.0 5000.0 0.0 even when I move my robot around (with the lidar on top)

this is the image I get -
image

any advice? what am I doing wrong?

@Avi-avidan
Copy link
Author

this is the map I get after slam.update() with 10,000 points (200 at a time) -
image

any advice would be greatly appreciated. thanks in advance.

@Avi-avidan
Copy link
Author

this is the 10000 points when I show it with matplotlib -
Screen Shot 2020-04-11 at 16 16 12

any advice will be appreciated. thanks.

@simondlevy
Copy link
Owner

Have you tried the sketch I already wrote for RPLidar A1?

@Avi-avidan
Copy link
Author

here are the prints after running python3 rpslam.py
Unable to init server: Could not connect: Connection refused
Unable to init server: Could not connect: Connection refused

(rpslam.py:20166): Gdk-CRITICAL **: 21:57:03.273: gdk_cursor_new_for_display: assertion 'GDK_IS_DISPLAY (display)' failed
Too many measurments in the input buffer: 711/500. Clearing buffer...
Too many measurments in the input buffer: 780/500. Clearing buffer...
Too many measurments in the input buffer: 778/500. Clearing buffer...
Too many measurments in the input buffer: 809/500. Clearing buffer...
Too many measurments in the input buffer: 784/500. Clearing buffer...
Too many measurments in the input buffer: 775/500. Clearing buffer...
Too many measurments in the input buffer: 771/500. Clearing buffer...
Too many measurments in the input buffer: 813/500. Clearing buffer...
Too many measurments in the input buffer: 781/500. Clearing buffer...
Too many measurments in the input buffer: 770/500. Clearing buffer...
Too many measurments in the input buffer: 784/500. Clearing buffer...
Too many measurments in the input buffer: 781/500. Clearing buffer...
Too many measurments in the input buffer: 770/500. Clearing buffer...
Too many measurments in the input buffer: 819/500. Clearing buffer...
Too many measurments in the input buffer: 784/500. Clearing buffer...
Too many measurments in the input buffer: 780/500. Clearing buffer...
Too many measurments in the input buffer: 782/500. Clearing buffer...
Too many measurments in the input buffer: 786/500. Clearing buffer...
Too many measurments in the input buffer: 783/500. Clearing buffer...
Too many measurments in the input buffer: 808/500. Clearing buffer...
Too many measurments in the input buffer: 784/500. Clearing buffer...

@Avi-avidan
Copy link
Author

I am ssh'ing from the terminal into the robot so display is unavailable.
any advice?

@Avi-avidan
Copy link
Author

Avi-avidan commented Apr 16, 2020

I got a scan plotted running the sketch in jupyter notebook. after replacing viz.display with matplotlib.pyplot -

import matplotlib.pyplot as plt
map_show = copy.deepcopy(mapbytes)
map_show = np.reshape(mapbytes, (500,500))
f = plt.figure(figsize=(10,10))
plt.imshow(map_show, cmap='gray')
plt.show()

Screen Shot 2020-04-16 at 22 19 33

thanks :)

@simondlevy
Copy link
Owner

Nice work, sorry for the trouble!

@Avi-avidan
Copy link
Author

no trouble. thanks again for this great repo and your timely support :)

@Thuong-ironman
Copy link

Hi,
I am using rplidar a1 and have an issue:
Too many bytes in the input buffer: 4010/3000. Cleaning buffer rplidar

Do you have any idea to solve this?

@jackhou66
Copy link

Hi, I am using rplidar a1 and have an issue: Too many bytes in the input buffer: 4010/3000. Cleaning buffer rplidar

Do you have any idea to solve this?

have you resolve this questions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants