Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
permocar
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
Model registry
Operate
Environments
Monitor
Incidents
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
Robert Hedman
permocar
Commits
d4efdb94
Commit
d4efdb94
authored
7 years ago
by
Robert Hedman
Browse files
Options
Downloads
Patches
Plain Diff
Sync, before ip stuff
parent
d39b2d6e
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
Cargo.lock
+7
-7
7 additions, 7 deletions
Cargo.lock
Cargo.toml
+1
-1
1 addition, 1 deletion
Cargo.toml
src/main.rs
+33
-12
33 additions, 12 deletions
src/main.rs
with
41 additions
and
20 deletions
Cargo.lock
+
7
−
7
View file @
d4efdb94
[[package]]
name = "Rorientation"
version = "0.1.0"
dependencies = [
"image 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "adler32"
name = "adler32"
version = "1.0.2"
version = "1.0.2"
...
@@ -213,6 +206,13 @@ dependencies = [
...
@@ -213,6 +206,13 @@ dependencies = [
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
"rand 0.3.18 (registry+https://github.com/rust-lang/crates.io-index)",
]
]
[[package]]
name = "rorientation"
version = "0.1.0"
dependencies = [
"image 0.17.0 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
[[package]]
name = "scoped_threadpool"
name = "scoped_threadpool"
version = "0.1.8"
version = "0.1.8"
...
...
This diff is collapsed.
Click to expand it.
Cargo.toml
+
1
−
1
View file @
d4efdb94
[package]
[package]
name
=
"
R
orientation"
name
=
"
r
orientation"
version
=
"0.1.0"
version
=
"0.1.0"
authors
=
[
"Robert Hedman <robert.hedman@mac.com>"
]
authors
=
[
"Robert Hedman <robert.hedman@mac.com>"
]
...
...
This diff is collapsed.
Click to expand it.
src/main.rs
+
33
−
12
View file @
d4efdb94
use
std
::
thread
;
use
std
::
thread
;
use
std
::
sync
::
mpsc
;
use
std
::
sync
::
mpsc
;
use
std
::
time
;
// should the map matrix be two dim array of const size, vecs of dynamic, or what?
const
ROWS
:
usize
=
50
;
const
ROWS
:
usize
=
50
;
const
COLS
:
usize
=
100
;
const
COLS
:
usize
=
100
;
fn
main
()
{
fn
main
()
{
let
map
=
[[
0u32
;
ROWS
];
COLS
];
let
mut
map
=
[[
0u32
;
ROWS
];
COLS
];
map
[
0
][
0
]
=
3
;
let
(
requestLocationTX
,
requestLocationRX
):
(
mpsc
::
Sender
<
bool
>
,
mpsc
::
Receiver
<
bool
>
)
=
mpsc
::
channel
();
println!
(
"{}, {}"
,
map
[
0
][
0
],
map
[
0
][
1
]);
let
(
sendLocationTX
,
sendLocationRX
):
(
mpsc
::
Sender
<
(
i32
,
i32
)
>
,
mpsc
::
Receiver
<
(
i32
,
i32
)
>
)
=
mpsc
::
channel
();
let
(
request_location_tx
,
request_location_rx
):
(
mpsc
::
Sender
<
bool
>
,
mpsc
::
Receiver
<
bool
>
)
=
mpsc
::
channel
();
let
(
send_location_tx
,
send_location_rx
):
(
mpsc
::
Sender
<
(
i32
,
i32
)
>
,
mpsc
::
Receiver
<
(
i32
,
i32
)
>
)
=
mpsc
::
channel
();
// location tracker
// location tracker
let
tracker
=
thread
::
spawn
(
move
||
{
let
tracker
=
thread
::
spawn
(
move
||
{
...
@@ -16,47 +24,60 @@ fn main() {
...
@@ -16,47 +24,60 @@ fn main() {
let
mut
pos
:
(
i32
,
i32
)
=
(
0
,
0
);
let
mut
pos
:
(
i32
,
i32
)
=
(
0
,
0
);
loop
{
loop
{
// get encoder data from arduino
// get encoder data from arduino
let
mut
t
:
i32
=
0
;
for
_
in
0
..
1000
{
t
=
t
+
1
;
};
for
_
in
0
..
1000
{
t
=
t
-
1
;
};
// update local variables
// update local variables
// check if position is requested
// check if position is requested
match
request
L
ocation
RX
.try_recv
()
{
match
request
_l
ocation
_rx
.try_recv
()
{
Ok
(
msg
)
=>
{
Ok
(
msg
)
=>
{
if
msg
==
false
{
if
msg
==
false
{
println!
(
"tracker got stop signal."
);
println!
(
"tracker got stop signal."
);
break
;
break
;
};
};
send
L
ocation
TX
.send
(
pos
)
.unwrap
();
send
_l
ocation
_tx
.send
(
pos
)
.unwrap
();
pos
.0
+=
1
;
pos
.0
+=
1
;
},
},
Err
(
e
)
=>
{
Err
(
_
)
=>
{
//println!("Error: {}, on recieving side.", e);
//println!("Error: {}, on recieving side.", e);
//thread::sleep_ms(100);
//thread::sleep_ms(100);
pos
.1
+=
1
;
},
},
};
};
};
};
println!
(
"tracker exiting with local pos: {:?}"
,
pos
);
});
});
// mapper (gets lidar data, requests position and updates its map.)
// mapper (gets lidar data, requests position and updates its map.)
let
mapper
=
thread
::
spawn
(
move
||
{
let
mapper
=
thread
::
spawn
(
move
||
{
println!
(
"mapper started."
);
println!
(
"mapper started."
);
// create empty map
// create empty map
let
mut
pos
:
(
i32
,
i32
)
=
(
0
,
0
);
let
mut
pos
:
(
i32
,
i32
)
;
//
= (0,0);
loop
{
loop
{
// request position data
// request position data
requestLocationTX
.send
(
true
)
.unwrap
();
request_location_tx
.send
(
true
)
.unwrap
();
pos
=
sendLocationRX
.recv
()
.unwrap
();
pos
=
send_location_rx
.recv
()
.unwrap
();
if
pos
.0
%
1000
==
0
{
println!
(
"mapper pos: {:?} "
,
pos
);
println!
(
"mapper pos: {:?} "
,
pos
);
};
// request lidar data
// request lidar data
// update map
// update map
if
pos
.0
==
100
{
if
pos
.0
==
100
0000
{
println!
(
"mapper done."
);
println!
(
"mapper done."
);
request
L
ocation
TX
.send
(
false
)
.unwrap
();
request
_l
ocation
_tx
.send
(
false
)
.unwrap
();
break
;
break
;
}
}
//thread::sleep(time::Duration::new(0,50*1000000)); // from ms to ns
};
};
...
...
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