Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RSDK-6164] Mimo pid updates #4290

Merged
merged 27 commits into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
358fe3e
MIMO on PID Block done, need to clean up code
mariapatni Aug 16, 2024
252a42a
added some comments and cleaned up some code
mariapatni Aug 16, 2024
21c3e33
ran linter
mariapatni Aug 16, 2024
31e3453
tune signals one at a time
JohnN193 Aug 20, 2024
1cbb1a1
feedback from john review
JohnN193 Aug 20, 2024
00644c8
test MIMO PID works for single signal case
JohnN193 Aug 20, 2024
b7900ee
disable mimo single case
JohnN193 Aug 20, 2024
63eeb2a
small test cleanup
JohnN193 Aug 20, 2024
8e60a2d
add back old test
JohnN193 Aug 20, 2024
9b2916a
tweak pid struct comments
JohnN193 Aug 20, 2024
9f80288
lint
JohnN193 Aug 21, 2024
311e05c
fix pid test
JohnN193 Aug 21, 2024
8bf5301
fix other tests and remove dupe test
JohnN193 Aug 21, 2024
343544f
tweak comment
JohnN193 Sep 4, 2024
5b86ac8
only confirm pid values are set when not using multi and add error lo…
JohnN193 Sep 4, 2024
c2506d6
Merge branch 'main' of github.com:viamrobotics/rdk into mimoPIDUpdates
JohnN193 Sep 4, 2024
598e704
Merge branch 'main' of github.com:viamrobotics/rdk into mimoPIDUpdates
JohnN193 Sep 26, 2024
22be53f
Merge branch 'main' of github.com:viamrobotics/rdk into mimoPIDUpdates
JohnN193 Oct 2, 2024
0ca4594
add string method to pidconfig
JohnN193 Oct 2, 2024
d2cba49
lint
JohnN193 Oct 3, 2024
756e5b8
write string differently
JohnN193 Oct 3, 2024
372f540
fix test
JohnN193 Oct 3, 2024
12303b2
remove single input output pid
JohnN193 Oct 3, 2024
4528d58
address comments
JohnN193 Oct 3, 2024
a983cfa
lint
JohnN193 Oct 3, 2024
87b1283
check for in progress tuning
JohnN193 Oct 9, 2024
7956825
tweak string
JohnN193 Oct 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions control/control_loop.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,17 +330,29 @@ func (l *Loop) GetConfig(ctx context.Context) Config {
func (l *Loop) MonitorTuning(ctx context.Context) {
// wait until tuning has started
for {
tuning := l.GetTuning(ctx)
if tuning {
break
// 100 Hz is probably faster than we need, but we needed at least a small delay because
// GetTuning will lock the PID block
if utils.SelectContextOrWait(ctx, 10*time.Millisecond) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can try to remove these if ya want. Was worried that calling GetTuning was affecting things at the time when I added this.

Copy link
Contributor

@martha-johnston martha-johnston Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is fine and probably safer. happy with leaving it.

tuning := l.GetTuning(ctx)
if tuning {
break
}
continue
}
l.logger.Error("error starting tuner")
return
}
// wait until tuning is done
for {
tuning := l.GetTuning(ctx)
if !tuning {
break
if utils.SelectContextOrWait(ctx, 10*time.Millisecond) {
tuning := l.GetTuning(ctx)
if !tuning {
break
}
continue
}
l.logger.Error("error waiting for tuner")
return
}
}

Expand Down
20 changes: 17 additions & 3 deletions control/control_signal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package control

import "sync"
import (
"sync"
)

// Signal holds any data passed between blocks.
type Signal struct {
Expand All @@ -23,11 +25,23 @@ func makeSignal(name string, blockType controlBlockType) *Signal {
return &s
}

// Make Signals returns a Signal object where the length of its signal[] array is dependent
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Make Signals returns a Signal object where the length of its signal[] array is dependent
// makeSignals returns a Signal object where the length of its signal[] array is dependent

// on the number of PIDSets from the config.
func makeSignals(name string, blockType controlBlockType, dimension int) *Signal {
var s Signal
s.dimension = dimension
s.signal = make([]float64, dimension)
s.time = make([]int, dimension)
s.name = name
s.blockType = blockType
return &s
}

// GetSignalValueAt returns the value of the signal at an index, threadsafe.
func (s *Signal) GetSignalValueAt(i int) float64 {
s.mu.Lock()
defer s.mu.Unlock()
if i > len(s.signal)-1 {
if !(i < len(s.signal)) {
return 0.0
}
return s.signal[i]
Expand All @@ -37,7 +51,7 @@ func (s *Signal) GetSignalValueAt(i int) float64 {
func (s *Signal) SetSignalValueAt(i int, val float64) {
s.mu.Lock()
defer s.mu.Unlock()
if i > len(s.signal)-1 {
if !(i < len(s.signal)) {
return
}
s.signal[i] = val
Expand Down
Loading
Loading