roboticafacil / coppeliasim_gridmap

CoppeliaSim GridMap plugin
GNU General Public License v3.0
9 stars 2 forks source link

Segmentation Fault when updateMapLaser #1

Open lfpvillegas opened 3 years ago

lfpvillegas commented 3 years ago

OS: Windows 10 Coppelia Sim Edu, Version 4.1.0. (rev. 1) 64 bits (serialization version 22) Qt Version 5.15.0, MSVC2019

Hi, I have been trying to use this plugin, but whenever I use method simGridMap.updateMapLaser(laserScan, pose) CoppeliaSim crashes.

The map windows is correctly created in black, but whenever I want to update the map, it crashes. I have also tried to update with dummy error like simGridMap.updateMapLaser({0,1}, {})

There is no error message shown. Only if I run from a console the error that appears is Segmentation Fault

I'm following the instructions of the following youtube video I'm using the Pioneer robot given in the CoppeliaSim library, I have only modify the sensors. They were ultrasonic and I changed them to be laser ones so I could use the updateMapLaser method.

I leave here some code for giving more context

` function sysCall_init() usensors={-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1} for i=1,16,1 do usensors[i]=sim.getObjectHandle("Pioneer_p3dx_ultrasonicSensor"..i) end motorLeft=sim.getObjectHandle("Pioneer_p3dx_leftMotor") motorRight=sim.getObjectHandle("Pioneer_p3dx_rightMotor") wheel_radius=0.975e-01 b = 0.1655

-- Odometria
odometry=sim.getObjectHandle('odometry')
position=sim.getObjectPosition(odometry,-1)
orientation=sim.getObjectOrientation(odometry,-1)
pose={position[1],position[2], orientation[3]}
math.randomseed(os.time())

-- Mapa
cell_size = 0.1
map_size= 50
p_max = 0.9
p_min = 0.1
laser_max_range= 5
laser_prec = 0.1
laser_sigma = 0.1
laser_plambda =0.8
laser_weight_hit =0.7
laser_weight_unexpected = 0.3
gridMapParams = {cell_size,map_size, p_max, p_min, laser_max_range, laser_prec, laser_sigma, laser_plambda,laser_weight_hit,laser_weight_unexpected}
result = simGridMap.init(gridMapParams, true)
simGridMap.updateMapLaser({0,1,0,2}, {1,1,0}) 

--Pose robot
--robot_pose = sim.getObjectHandle('robot_pose')

noDetectionDist=0.5
maxDetectionDist=0.2
detect={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
braitenbergL={-0.2,-0.4,-0.6,-0.8,-1,-1.2,-1.4,-1.6, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}
braitenbergR={-1.6,-1.4,-1.2,-1,-0.8,-0.6,-0.4,-0.2, 0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}
v0=2

end`

` function sysCall_sensing() odometry=sim.getObjectHandle('odometry') position=sim.getObjectPosition(odometry,-1) orientation=sim.getObjectOrientation(odometry,-1) pose={position[1],position[2], orientation[3]} pose=updateOdometry(pose)

for i=1,16,1 do
    result,distance, detected_point=sim.readProximitySensor(usensors[i])
    position=sim.getObjectPosition(usensors[i],-1)
    orientation=sim.getObjectOrientation(usensors[i],-1)
    pose={position[1],position[2], orientation[3]}

    if(detected_point ~= nil) then
        laserScan = {detected_point[3],0}
        print("Punto", pose, laserScan)
        simGridMap.updateMapLaser(laserScan, pose)
    end
end

end`

Thanks and Regards

lfpvillegas commented 3 years ago

This is also happening with last version of Coppelia Sim 4.2.0 (rev 5)