Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MicroCART
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor 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
Distributed Autonomous Networked Control Lab
MicroCART
Commits
eb0a7ca7
Commit
eb0a7ca7
authored
8 years ago
by
dawehr
Browse files
Options
Downloads
Plain Diff
Merge branch 'commands-dev' into 'master'
New Commands Structure See merge request
!3
parents
c641dbad
0d242db9
No related branches found
No related tags found
1 merge request
!3
New Commands Structure
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
quad/scripts/stress_tests.py
+30
-9
30 additions, 9 deletions
quad/scripts/stress_tests.py
quad/sw/modular_quad_pid/src/callbacks.c
+1
-1
1 addition, 1 deletion
quad/sw/modular_quad_pid/src/callbacks.c
with
31 additions
and
10 deletions
quad/scripts/stress_tests.py
+
30
−
9
View file @
eb0a7ca7
...
...
@@ -3,6 +3,7 @@
import
sys
import
random
from
time
import
sleep
import
struct
import
serial
...
...
@@ -29,7 +30,6 @@ def read_packet(ser, raw=False):
length
=
int
.
from_bytes
(
header
[
5
:
7
],
byteorder
=
'
little
'
)
data
=
ser
.
read
(
length
)
checksum
=
ser
.
read
()
print
(
checksum
)
if
raw
:
return
header
+
data
+
checksum
else
:
...
...
@@ -62,10 +62,8 @@ def check_test(ser, n_sent, size_sent, old_status):
def
test_checksum
(
ser
):
print
(
"
Checking if received checksum is valid
"
)
# Send query packet
ser
.
write
(
create_msg
(
0
,
2
,
0
,
b
''
))
ser
.
write
(
create_msg
(
2
,
0
,
b
''
))
raw_data
=
read_packet
(
ser
,
True
)
print
(
"
Raw:
"
)
print
(
raw_data
.
hex
())
given_checksum
=
raw_data
[
-
1
]
computed_checksum
=
0
for
i
in
range
(
len
(
raw_data
)
-
1
):
...
...
@@ -108,11 +106,33 @@ def test_bad_checksum(ser, cur_status, size=30):
return
check_test
(
ser
,
0
,
0
,
cur_status
)
def
test_get_set
(
ser
):
print
(
"
Checking Get/Set Commands
"
)
for
cntl_id
in
range
(
9
):
for
const_id
in
range
(
4
):
to_set
=
random
.
random
()
#set_packet = create_msg()
print
(
"
Checking Get/Set Commands...
"
)
passed
=
True
for
cntl_id
in
range
(
9
):
for
const_id
in
range
(
4
):
to_set
=
random
.
random
()
# Construct the set command packet
set_data
=
bytes
([
cntl_id
,
const_id
])
set_data
+=
struct
.
pack
(
"
<f
"
,
to_set
)
set_packet
=
create_msg
(
7
,
0
,
set_data
)
ser
.
write
(
set_packet
)
# Construct the get command packet
get_packet
=
create_msg
(
8
,
0
,
bytes
([
cntl_id
,
const_id
]))
ser
.
write
(
get_packet
)
# Get the just-set value
resp
=
read_packet
(
ser
)
resp_cntl
=
resp
[
0
]
resp_cnst
=
resp
[
1
]
resp_val
=
struct
.
unpack
(
'
f
'
,
resp
[
2
:
6
])[
0
]
if
resp_cntl
!=
cntl_id
or
resp_cnst
!=
const_id
or
abs
(
resp_val
-
to_set
)
>
1e-5
:
print
(
"
Failed get/set test. Expected controller
"
+
str
(
cntl_id
)
+
"
, constant
"
+
str
(
const_id
)
+
"
, value
"
+
str
(
to_set
))
print
(
"
Received
"
+
str
(
resp_cntl
)
+
"
, constant
"
+
str
(
resp_cnst
)
+
"
, value
"
+
str
(
resp_val
))
passed
=
False
ret_status
=
query_received
(
ser
)
return
passed
,
ret_status
if
__name__
==
'
__main__
'
:
with
serial
.
Serial
(
'
/dev/ttyUSB0
'
,
921600
,
timeout
=
5
)
as
ser
:
...
...
@@ -126,4 +146,5 @@ if __name__ == '__main__':
passed
,
status
=
test_blast
(
ser
,
status
,
150
,
80
)
passed
,
status
=
test_bad_checksum
(
ser
,
status
)
passed
,
status
=
test_checksum
(
ser
)
passed
,
status
=
test_get_set
(
ser
)
This diff is collapsed.
Click to expand it.
quad/sw/modular_quad_pid/src/callbacks.c
+
1
−
1
View file @
eb0a7ca7
...
...
@@ -120,7 +120,7 @@ int cb_setparam(modular_structs_t *structs)
// Get the controller ID, parameter ID, parameter value
u8
controller_id
=
uart_buff_data_get_u8
(
0
);
u8
param_id
=
uart_buff_data_get_u8
(
1
);
float
param_val
=
uart_buff_data_get_float
(
3
);
float
param_val
=
uart_buff_data_get_float
(
2
);
// Check to make sure the IDs are in bounds
if
(
controller_id
>=
MAX_CONTROLLER_ID
||
param_id
>=
MAX_CONTROL_PARAM_ID
)
...
...
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