Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
csm
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
labrobotica
algorithms
csm
Commits
d0122473
Commit
d0122473
authored
15 years ago
by
Andrea Censi
Browse files
Options
Downloads
Patches
Plain Diff
added purify command
parent
00ebdd3e
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
sm/CMakeLists.txt
+1
-0
1 addition, 0 deletions
sm/CMakeLists.txt
sm/apps/ld_purify.c
+87
-0
87 additions, 0 deletions
sm/apps/ld_purify.c
sm/apps/ld_resample.c
+16
-26
16 additions, 26 deletions
sm/apps/ld_resample.c
sm/csm/laser_data.c
+1
-1
1 addition, 1 deletion
sm/csm/laser_data.c
with
105 additions
and
27 deletions
sm/CMakeLists.txt
+
1
−
0
View file @
d0122473
...
@@ -98,6 +98,7 @@ new_executable(ld_remove_doubles)
...
@@ -98,6 +98,7 @@ new_executable(ld_remove_doubles)
new_executable
(
ld_alternate
)
new_executable
(
ld_alternate
)
new_executable
(
ld_recover
)
new_executable
(
ld_recover
)
new_executable
(
ld_purify
)
new_executable
(
ld_select
)
new_executable
(
ld_select
)
new_executable
(
ld_cluster_curv
)
new_executable
(
ld_cluster_curv
)
new_executable
(
ld_linearize
)
new_executable
(
ld_linearize
)
...
...
This diff is collapsed.
Click to expand it.
sm/apps/ld_purify.c
0 → 100644
+
87
−
0
View file @
d0122473
#include
<gsl/gsl_rng.h>
#include
<gsl/gsl_randist.h>
#include
<math.h>
#include
<libgen.h>
#include
<options/options.h>
#include
"../csm/csm_all.h"
void
purify
(
LDP
ld
,
double
threshold_min
,
double
threshold_max
);
struct
ld_purify_params
{
double
threshold_min
,
threshold_max
;
const
char
*
file_input
;
const
char
*
file_output
;
};
int
main
(
int
argc
,
const
char
*
argv
[])
{
sm_set_program_name
(
argv
[
0
]);
options_banner
(
"ld_purify: Makes sure that the file format is valid.
\n
* Sets valid=0 if reading is outside interval "
);
struct
ld_purify_params
p
;
struct
option
*
ops
=
options_allocate
(
20
);
options_double
(
ops
,
"threshold_min"
,
&
p
.
threshold_min
,
0
.
01
,
"Sets valid=0 if readings are less than this threshold."
);
options_double
(
ops
,
"threshold_max"
,
&
p
.
threshold_max
,
79
.
0
,
"Sets valid=0 if readings are more than this threshold."
);
options_string
(
ops
,
"in"
,
&
p
.
file_input
,
"stdin"
,
"Input file "
);
options_string
(
ops
,
"out"
,
&
p
.
file_output
,
"stdout"
,
"Output file "
);
if
(
!
options_parse_args
(
ops
,
argc
,
argv
))
{
options_print_help
(
ops
,
stderr
);
return
-
1
;
}
FILE
*
in
=
open_file_for_reading
(
p
.
file_input
);
if
(
!
in
)
return
-
3
;
FILE
*
out
=
open_file_for_writing
(
p
.
file_output
);
if
(
!
out
)
return
-
2
;
LDP
ld
;
int
count
=
-
1
;
while
(
(
ld
=
ld_from_json_stream
(
in
)))
{
purify
(
ld
,
p
.
threshold_min
,
p
.
threshold_max
);
if
(
!
ld_valid_fields
(
ld
))
{
sm_error
(
"Wait, we didn't purify enough (#%d in file)
\n
"
,
count
);
continue
;
}
ld_write_as_json
(
ld
,
out
);
ld_free
(
ld
);
}
return
0
;
}
void
purify
(
LDP
ld
,
double
threshold_min
,
double
threshold_max
)
{
for
(
int
i
=
0
;
i
<
ld
->
nrays
;
i
++
)
{
if
(
!
ld
->
valid
[
i
])
continue
;
double
rho
=
ld
->
readings
[
i
];
if
(
is_nan
(
rho
)
|
(
rho
<
threshold_min
)
|
(
rho
>
threshold_max
)
)
{
ld
->
readings
[
i
]
=
GSL_NAN
;
ld
->
valid
[
i
]
=
0
;
ld
->
alpha
[
i
]
=
GSL_NAN
;
ld
->
alpha_valid
[
i
]
=
0
;
}
}
}
This diff is collapsed.
Click to expand it.
sm/apps/ld_resample.c
+
16
−
26
View file @
d0122473
...
@@ -24,27 +24,11 @@ int main(int argc, const char ** argv) {
...
@@ -24,27 +24,11 @@ int main(int argc, const char ** argv) {
struct
option
*
ops
=
options_allocate
(
3
);
struct
option
*
ops
=
options_allocate
(
3
);
options_double
(
ops
,
"interval"
,
&
p
.
interval
,
sqrt
(
2
.
0
),
" 1 = no resampling"
);
options_double
(
ops
,
"interval"
,
&
p
.
interval
,
sqrt
(
2
.
0
),
" 1 = no resampling"
);
options_int
(
ops
,
"seed"
,
&
p
.
seed
,
0
,
"Seed for random number generator (if 0, use GSL_RNG_SEED env. variable)."
);
if
(
!
options_parse_args
(
ops
,
argc
,
argv
))
{
if
(
!
options_parse_args
(
ops
,
argc
,
argv
))
{
/* fprintf(stderr, "A simple program for adding slip to odometry \n\n"
"The 'odometry' field is set to 'true_pose' + noise.\n"
"If 'true_pose' is not available, then the 'odometry' \n"
"field is set to 'odometry' + noise.\n\n"
"Note: this program does *not* simulate the effect of \n"
"slip or odometry error in a realistic way; each scan \n"
"in the file is considered separately, the error does \n"
"not depend on the traveled distance, etc.\n\n");*/
options_print_help
(
ops
,
stderr
);
options_print_help
(
ops
,
stderr
);
return
-
1
;
return
-
1
;
}
}
gsl_rng_env_setup
();
rng
=
gsl_rng_alloc
(
gsl_rng_ranlxs0
);
if
(
p
.
seed
!=
0
)
gsl_rng_set
(
rng
,
(
unsigned
int
)
p
.
seed
);
int
count
=
-
1
;
int
count
=
-
1
;
LDP
ld
;
LDP
ld
;
while
(
(
ld
=
ld_read_smart
(
stdin
)))
{
while
(
(
ld
=
ld_read_smart
(
stdin
)))
{
...
@@ -73,27 +57,33 @@ int main(int argc, const char ** argv) {
...
@@ -73,27 +57,33 @@ int main(int argc, const char ** argv) {
LDP
ld_resample
(
LDP
ld
)
{
LDP
ld_resample
(
LDP
ld
)
{
/* FIXME magic number */
/* FIXME magic number */
int
n
=
(
int
)
(
floor
(
ld
->
nrays
/
p
.
interval
))
-
4
;
int
n
=
(
int
)
(
floor
(
ld
->
nrays
/
p
.
interval
));
LDP
ld2
=
ld_alloc_new
(
n
);
LDP
ld2
=
ld_alloc_new
(
n
);
int
k
;
int
k
;
for
(
k
=
0
;
k
<
n
;
k
++
)
{
for
(
k
=
0
;
k
<
n
;
k
++
)
{
double
index
=
k
*
p
.
interval
;
double
index
=
k
*
p
.
interval
;
int
i
=
(
int
)
floor
(
index
);
int
i
=
(
int
)
floor
(
index
);
int
j
=
i
+
1
;
double
a
=
1
-
(
index
-
i
);
double
a
=
1
-
(
index
-
i
);
ld2
->
theta
[
k
]
=
a
*
ld
->
theta
[
i
]
+
(
1
-
a
)
*
ld
->
theta
[
i
+
1
];
if
(
is_nan
(
ld2
->
theta
[
k
]))
{
sm_debug
(
"Hey, k=%d theta[%d]=%f theta[%d]=%f
\n
"
,
k
,
i
,
ld
->
theta
[
i
],
i
+
1
,
ld
->
theta
[
i
+
1
]);
}
if
(
!
ld
->
valid
[
i
]
||
!
ld
->
valid
[
i
+
1
])
{
if
(
(
j
>=
ld
->
nrays
)
||
!
ld
->
valid
[
i
]
||
!
ld
->
valid
[
j
])
{
ld2
->
valid
[
k
]
=
0
;
ld2
->
valid
[
k
]
=
0
;
ld2
->
readings
[
k
]
=
NAN
;
ld2
->
readings
[
k
]
=
NAN
;
ld2
->
alpha_valid
[
k
]
=
0
;
ld2
->
alpha
[
k
]
=
NAN
;
ld2
->
theta
[
k
]
=
ld
->
theta
[
i
];
}
else
{
}
else
{
ld2
->
readings
[
k
]
=
a
*
ld
->
readings
[
i
]
+
(
1
-
a
)
*
ld
->
readings
[
i
+
1
];
ld2
->
theta
[
k
]
=
a
*
ld
->
theta
[
i
]
+
(
1
-
a
)
*
ld
->
theta
[
j
];
if
(
is_nan
(
ld2
->
theta
[
k
]))
{
sm_debug
(
"Hey, k=%d theta[%d]=%f theta[%d]=%f
\n
"
,
k
,
i
,
ld
->
theta
[
i
],
j
,
ld
->
theta
[
j
]);
}
ld2
->
readings
[
k
]
=
a
*
ld
->
readings
[
i
]
+
(
1
-
a
)
*
ld
->
readings
[
j
];
ld2
->
valid
[
k
]
=
1
;
ld2
->
valid
[
k
]
=
1
;
}
}
...
...
This diff is collapsed.
Click to expand it.
sm/csm/laser_data.c
+
1
−
1
View file @
d0122473
...
@@ -230,7 +230,7 @@ int ld_valid_fields(LDP ld) {
...
@@ -230,7 +230,7 @@ int ld_valid_fields(LDP ld) {
}
else
{
}
else
{
/* ray not valid, but checking theta anyway */
/* ray not valid, but checking theta anyway */
if
(
is_nan
(
th
))
{
if
(
is_nan
(
th
))
{
sm_error
(
"Ray #%d: valid = %d but theta = %f"
,
sm_error
(
"Ray #%d: valid = %d but theta = %f
\n
"
,
i
,
ld
->
valid
[
i
],
th
);
i
,
ld
->
valid
[
i
],
th
);
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment