Quantcast

RangerProxy GetRange(0) crashes player

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

RangerProxy GetRange(0) crashes player

JanStevens
Dear mailing subscribers,

I've got a ranger (sonars) and ranger (laser). For some reason I'm unable to get any measurements out of the sonars and lasers. My code is basically this:

RangerProxy sonarProxy(&robot, 0);
sonarProxy.RequestGeom();

cout << "Sonar: " << sonarProxy.GetRange(0) << endl;


This crashes with the following error:

RangerProxy::GetRange(-1) : index out of bounds
*** Exited with return code: 255 ***


I also printed out GetElementCount(), GetRangeCount() and sonarProxy to see if everything is configured right. I get the following code:

There are 8 individual range sensors.
There are 0 individual range counts.
#Ranger (62:0)
Device pose: (0, 0, 0), (0, 0, 0)
Device size: (0.15, 0.15, 0)
8 sensors:
  Pose: (0.075, 0.13, 0), (0, 0, 1.5708) Size: (0.01, 0.05, 0.01)
  Pose: (0.115, 0.115, 0), (0, 0, 0.872665) Size: (0.01, 0.05, 0.01)
  Pose: (0.15, 0.08, 0), (0, 0, 0.523599) Size: (0.01, 0.05, 0.01)
  Pose: (0.17, 0.025, 0), (0, 0, 0.174533) Size: (0.01, 0.05, 0.01)
  Pose: (0.17, -0.025, 0), (0, 0, -0.174533) Size: (0.01, 0.05, 0.01)
  Pose: (0.15, -0.08, 0), (0, 0, -0.523599) Size: (0.01, 0.05, 0.01)
  Pose: (0.115, -0.115, 0), (0, 0, -0.872665) Size: (0.01, 0.05, 0.01)
  Pose: (0.075, -0.13, 0), (0, 0, -1.5708) Size: (0.01, 0.05, 0.01)
Configuration:
Minimum angle: -0.1309 Maximum angle: 0.1309 Angular resolution: 0.261799
Minimum range: 0.02 Maximum range: 5 Range resolution: 0.02
Scanning frequency: 10


Following are my configuration files
# 1-pf.cfg
# Author: Jan Stevens

driver
(
        name "stage"
        plugin "stageplugin"
        provides ["simulation:0"]

        # load the named file into the simulator
        worldfile "../stage/1-pf.world"
)

driver
(
        name "stage"
        provides ["position2d:0" "ranger:0" "ranger:1" "fiducial:0"]
        model "fritz"
)

driver
(
  name "stage"
  provides ["graphics3d:0"]
  model "D31"
)

driver
(
  name "mapfile"
  provides ["map:0"]
  resolution 0.05
  filename "../stage/D31.png"
)

# 1-pf.world
# World file for the Particle Filter - Development
# Author: Jan Stevens

include "map.inc"
include "lm.inc"
include "pioneer.inc"
include "sick.inc"

name "1-Particle Filter - Development"

window
(
    size [ 640 480 ] # in pixels
    scale 32.210         # pixels per meter
    rotate [ 0.000 0.000 ]
    center [ 0 0 ]
    show_data 1
)

floorplan
(
    name "D31"
    bitmap "D31.png"
    size [ 14.840 6.850 2.000 ]
    pose [0 0 0 0]
)

fancypioneer2dx
(
name "fritz"
  pose [0.0 0 0 0.0]
  color "green"
 
)

lm(name "Fid1" pose [-7.2 3.2 0 0] color "red" fiducial_return 1)
lm(name "Fid2" pose [0 3.2 0 0] color "green" fiducial_return 2)
lm(name "Fid3" pose [7.2 3.2 0 0] color "yellow" fiducial_return 3)
lm(name "Fid4" pose [7.2 -3.2 0 0] color "purple" fiducial_return 4)
lm(name "Fid5" pose [0 -3.2 0 0] color "pink" fiducial_return 5)
lm(name "Fid6" pose [-7.2 -3.2 0 0] color "brown" fiducial_return 6)

#Edited pioneer.inc, removed stuff we dont need
# Desc: Device definitions for Activemedia robots.
# Author: Richard Vaughan, Andrew Howard,  Luis Riazuelo
# Date: 10 Jun 2002
# CVS: $Id: pioneer.inc,v 1.30 2008-01-15 01:25:42 rtv Exp $

#  prototype for p2dx sonar sensors
define p2dxsonar sensor
(
  # define the size of each transducer [xsize ysize zsize] in meters
  size [0.01 0.05 0.01 ]
 
  # define the range bounds [min max]
  range [0.02 5.0]
 
  # define the angular field of view in degrees
  fov 15
 
  # define the number of samples spread over the fov
  samples 1
 
  # define the color that ranges are drawn in the gui
  color_rgba [ 0 1 0 0.2 ]
)


define p2dx_sonar_front ranger
(
 # 8 transducers spread about the robot as follows
  p2dxsonar( pose [ 0.075 0.130 0 90 ] )
  p2dxsonar( pose [ 0.115 0.115 0 50 ] )
  p2dxsonar( pose [ 0.150 0.080 0 30 ] )
  p2dxsonar( pose [ 0.170 0.025 0 10 ] )
  p2dxsonar( pose [ 0.170 -0.025 0 -10 ] )
  p2dxsonar( pose [ 0.150 -0.080 0 -30 ] )
  p2dxsonar( pose [ 0.115 -0.115 0 -50 ] )
  p2dxsonar( pose [ 0.075 -0.130 0 -90 ] )
)

define fancypioneer2dx position
(
  # Merged so we dont have to look at 152200 definitions.
 
 # actual size
  size [0.44 0.38 0.22] # sizes from MobileRobots' web site

  # the pioneer's center of rotation is offset from its center of area
  origin [-0.04 0 0 0]

  # draw a nose on the robot so we can see which way it points
  gui_nose 1

  # estimated mass in KG
  mass 23.0
  # differential steering model
  drive "diff"
 
  color "red" # Default color.
  obstacle_return 1           # Can hit things.
  ranger_return 0.5             # reflects sonar beams
  blob_return 1               # Seen by blobfinders  
  fiducial_return 1           # Seen as "1" fiducial finders

  localization "gps"          
  localization_origin [0 0 0 0] # Start odometry at (0, 0, 0).

  # alternative odometric localization with simple error model
  # localization "odom"         # Change to "gps" to have impossibly perfect, global odometry
  #  odom_error [ 0.05 0.05 0.1 ]   # Odometry error or slip in X, Y and Theta
                                    # (Uniform random distribution)  

  # four DOF kinematics limits
  # [ xmin xmax ymin ymax zmin zmax amin amax ]
  velocity_bounds [-0.5 0.5 0 0 0 0 -90.0 90.0 ]
  acceleration_bounds [-0.5 0.5 0 0 0 0 -90 90.0 ]
 
  # main body
  block
  (
    points 8
    point[0] [ -0.185 -0.135 ]
    point[1] [  0.095 -0.135 ]
    point[2] [  0.11  -0.08  ]
    point[3] [  0.11   0.08  ]
    point[4] [  0.095  0.135 ]
    point[5] [ -0.185  0.135 ]
    point[6] [ -0.215  0.1   ]
    point[7] [ -0.215 -0.1   ]
    z [ 0.059 0.234 ]
  )

  # sonar case
  block
  (
    points 9
    point[0]  [ -0.135  0.136 ]
    point[1]  [ -0.185  0.136 ]
    point[2]  [ -0.223  0.101 ]
    point[3]  [ -0.248  0.054 ]
    point[4]  [ -0.258  0     ]
    point[5]  [ -0.248 -0.054 ]
    point[6]  [ -0.223 -0.101 ]
    point[7]  [ -0.185 -0.136 ]
    point[8]  [ -0.135 -0.136 ]
    z [ 0.184 0.234 ]
  )

  # sonar case
  block
  (
    points 9
    point[0]  [ 0.046 -0.136 ]
    point[1]  [ 0.096 -0.136 ]
    point[2]  [ 0.134 -0.101 ]
    point[3]  [ 0.159 -0.054 ]
    point[4]  [ 0.168  0     ]
    point[5]  [ 0.159  0.054 ]
    point[6]  [ 0.134  0.101 ]
    point[7]  [ 0.096  0.136 ]
    point[8]  [ 0.046  0.136 ]
    z [ 0.184 0.234 ]
  )
 
  # left wheel
  block
  (
    points 4
    point[0] [  0.083  0.177 ]
    point[1] [ -0.083  0.177 ]
    point[2] [ -0.083  0.140 ]
    point[3] [  0.083  0.140 ]
    z [0 0.165 ]
  )

  # right wheel
  block
  (
    points 4
    point[0] [  0.083  -0.14 ]
    point[1] [ -0.083  -0.14 ]
    point[2] [ -0.083  -0.177 ]
    point[3] [  0.083  -0.177 ]
    z [ 0 0.165 ]
  )

  # castor
  block
  (
    points 4
    point[3] [ -0.2475  0.012 ]
    point[2] [ -0.1825  0.012 ]
    point[1] [ -0.1825 -0.012 ]
    point[0] [ -0.2475 -0.012 ]
    z [ 0 0.065 ]
  )
 
  # lid
  block
  (
    points 22
    point[21] [  0.174 0 ]
    point[20] [  0.166 -0.056 ]
    point[19] [  0.145 -0.107 ]
    point[18] [  0.112 -0.155 ]
    point[17] [  0.064 -0.190 ]
    point[16] [  -0.074 -0.190 ]
    point[15] [  -0.096 -0.160 ]
    point[14] [  -0.151 -0.160 ]
    point[13] [  -0.2   -0.155 ]
    point[12] [  -0.236 -0.107 ]
    point[11] [  -0.256 -0.056 ]
    point[10] [  -0.264  0     ]
    point[9] [  -0.256  0.056 ]
    point[8] [ -0.236  0.107 ]
    point[7] [ -0.2    0.155 ]
    point[6] [ -0.151  0.160 ]
    point[5] [ -0.096  0.160 ]
    point[4] [ -0.074  0.190 ]
    point[3] [  0.064  0.190 ]
    point[2] [  0.112  0.155 ]
    point[1] [  0.145  0.107 ]
    point[0] [  0.166  0.056 ]
    z [ 0.234 0.24 ]
  )
   p2dx_sonar_front( pose [0 0 -0.03 0] )
 
  sicklaser( size [0.1 0.1 0.1] )
  fiducial (range_max 8 range_max_id 8 alwayson 1)
  localization_origin [ 0 0 0 0 ]
 
)


Thanks,
Kind Regards,

Jan Stevens
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RangerProxy GetRange(0) crashes player

JanStevens
And I forgot robot.Read(); but that didn't solve everything.

When I include the GetRange now it still crashes, when I leave it out I see that sonarProxy get 8 ranger readings.

When I print out sonarProxy for the first time it registers 0 individual range counts (GetRangeCounts), so my code GetRange(2) for example, crashes. If I remove that bit of code and only print sonarProxy I see that during the second iteration all 8 range counts are detected.

Don't know if I should program a check or this is a bug or expected behavior. Solved my problem by first checking if GetRangeCount > 0 and then request for Range measurements.

Kind Regards,

Jan Stevens
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RangerProxy GetRange(0) crashes player

Fred Labrosse
On Saturday 26 January 2013 03:42:32 JanStevens wrote:

> And I forgot *robot.Read();* but that didn't solve everything.
>
> When I include the GetRange now it still crashes, when I leave it out I see
> that sonarProxy get 8 ranger readings.
>
> When I print out sonarProxy for the first time it registers 0 individual
> range counts (GetRangeCounts), so my code GetRange(2) for example, crashes.
> If I remove that bit of code and only print sonarProxy I see that during the
> second iteration all 8 range counts are detected.
>
> Don't know if I should program a check or this is a bug or expected
> behavior. Solved my problem by first checking if GetRangeCount > 0 and then
> request for Range measurements.

I might be wrong, but this looks like an error I had at some point.  With the
ranger, you have to call:

         RequestConfigure();
         RequestGeom();

Hope this helps.

Fred

>
> Kind Regards,
>
> Jan Stevens
>
>
>
> -----
> My Blog: http://www.fritz-hut.com
> --
> View this message in context:
> http://player-stage-gazebo.10965.n7.nabble.com/RangerProxy-GetRange-0-crash
> es-player-tp18558p18559.html Sent from the playerstage-users mailing list
> archive at Nabble.com.
>
> ----------------------------------------------------------------------------
> -- Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS, MVC,
> Windows 8 Apps, JavaScript and much more. Keep your skills current with
> LearnDevNow - 3,200 step-by-step video tutorials by Microsoft MVPs and
> experts. ON SALE this month only -- learn more at:
> http://p.sf.net/sfu/learnnow-d2d
> _______________________________________________
> Playerstage-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/playerstage-users

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: RangerProxy GetRange(0) crashes player

Rich Mattes-2
In reply to this post by JanStevens
On 01/26/2013 06:42 AM, JanStevens wrote:

> And I forgot *robot.Read();* but that didn't solve everything.
>
> When I include the GetRange now it still crashes, when I leave it out I see
> that sonarProxy get 8 ranger readings.
>
> When I print out sonarProxy for the first time it registers 0 individual
> range counts (GetRangeCounts), so my code GetRange(2) for example, crashes.
> If I remove that bit of code and only print sonarProxy I see that during the
> second iteration all 8 range counts are detected.
>
> Don't know if I should program a check or this is a bug or expected
> behavior. Solved my problem by first checking if GetRangeCount > 0 and then
> request for Range measurements.
>
> Kind Regards,
>
> Jan Stevens
>

This is a Player bug.  When first create a RangerProxy object, it tries
to ask the underlying driver for configuration information and geometry
information immediately (via RequestConfigure() and RequestGeom()).  At
least, the version in SVN does, Player 3.0.2 does not.  Anyway, that's
why when you print out your sonarProxy object, you see that all of the
geometric information (poses, etc.) is filled in.  What the RangerProxy
*doesn't* know anything about yet is the underlying range sensor
measurements (the RangeCount, Ranges etc.)  It won't know about those
until it processes its first ranger data message during a call to Read();.

When you ask for a range measurement via GetRange(), playerc++ does a
quick check to make sure it can fulfill that request, by checking:

if (aIndex > mDevice->ranges_count) { throw error }

This is an off-by-one error.  If you ask for index 0, and you have zero
ranges, it is going to try to get index 0 anyway.  When it does that, it
accesses its internal array of ranges which hasn't been allocated yet,
and segfaults.  What it should do is check for something like:

if (aIndex  >= mDevice->ranges_count) { throw error }

That way, if you have 1 range, you can only ask for range 0, if you have
5 ranges, you can only ask for array indices 0 to 4, and if you have no
ranges, you can't ask for anything without throwing an error.

For now, you can work around the error by using a loop like:

while (!sonarProxy.isValid()) { robot.Read();}

at the beginning of your client.  This ensures your ranger proxy has
received a data message and has valid information for you.  I'll fix the
off-by-one error in SVN now.

Rich

------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Playerstage-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/playerstage-users
Loading...