• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cbruiz / printhor / 13753907916

10 Mar 2025 12:08AM UTC coverage: 90.771% (+0.2%) from 90.599%
13753907916

Pull #35

github

web-flow
Merge 76633dfa7 into cc61929b1
Pull Request #35: Features/s_plot recovery

442 of 472 new or added lines in 7 files covered. (93.64%)

4 existing lines in 3 files now uncovered.

14832 of 16340 relevant lines covered (90.77%)

734462.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

93.02
/printhor/src/bin/instrumentation/datapoints.rs
1
use crate::{control, hwa};
2

3
pub(crate) struct DataPointsDimension {
4
    time_offset: f64,
5
    last_time: f64,
6
    point_offset: f64,
7
    last_point: f64,
8
    /// Position datapoint time in secs
9
    pub times: Vec<f64>,
10
    /// Position datapoint displacement in units
11
    pub points: Vec<f64>,
12
}
13

14
impl DataPointsDimension {
15
    pub fn new() -> Self {
4✔
16
        Self {
4✔
17
            time_offset: 0.0,
4✔
18
            last_time: 0.0,
4✔
19
            point_offset: 0.0,
4✔
20
            last_point: 0.0,
4✔
21
            times: vec![0.0],
4✔
22
            points: vec![0.0],
4✔
23
        }
4✔
24
    }
4✔
25

26
    pub fn displace(&mut self) {
38✔
27
        self.displace_time();
38✔
28
        self.point_offset += self.last_point;
38✔
29
    }
38✔
30

31
    pub fn displace_time(&mut self) {
76✔
32
        self.time_offset += self.last_time;
76✔
33
    }
76✔
34

35
    pub fn push_relative(&mut self, time: f64, point: f64) {
157✔
36
        self.last_time = time;
157✔
37
        self.last_point = point;
157✔
38
        self.times.push(self.time_offset + self.last_time);
157✔
39
        self.points.push(self.point_offset + self.last_point);
157✔
40
    }
157✔
41

42
    pub fn push_time_relative(&mut self, time: f64, point: f64) {
19✔
43
        self.last_time = time;
19✔
44
        self.last_point = point;
19✔
45
        self.times.push(self.time_offset + self.last_time);
19✔
46
        self.points.push(self.last_point);
19✔
47
    }
19✔
48
}
49

50
pub(crate) struct DataPoints {
51
    pub current_segment_id: usize,
52
    pub current_micro_segment_id: usize,
53
    pub total_displacement: hwa::math::Real,
54

55
    pub segment_position_marks: DataPointsDimension,
56
    pub interpolated_positions: DataPointsDimension,
57

58
    pub segment_velocity_marks: DataPointsDimension,
59
    pub interpolated_velocities: DataPointsDimension,
60
}
61

62
impl DataPoints {
63
    pub fn new() -> Self {
1✔
64
        Self {
1✔
65
            current_segment_id: 0,
1✔
66
            current_micro_segment_id: 0,
1✔
67
            total_displacement: hwa::math::ZERO,
1✔
68

1✔
69
            segment_position_marks: DataPointsDimension::new(),
1✔
70
            interpolated_positions: DataPointsDimension::new(),
1✔
71

1✔
72
            segment_velocity_marks: DataPointsDimension::new(),
1✔
73
            interpolated_velocities: DataPointsDimension::new(),
1✔
74
        }
1✔
75
    }
1✔
76

77
    pub fn segment_starts(&mut self, trajectory: &control::motion::SCurveMotionProfile) {
19✔
78
        self.current_segment_id += 1;
19✔
79
        self.current_micro_segment_id = 0;
19✔
80
        self.segment_position_marks.push_relative(
19✔
81
            self.interpolated_positions.last_time,
19✔
82
            self.interpolated_positions.last_point,
19✔
83
        );
19✔
84
        self.segment_velocity_marks.push_time_relative(
19✔
85
            self.interpolated_positions.last_time,
19✔
86
            trajectory.v_0.to_f64(),
19✔
87
        )
19✔
88
    }
19✔
89
    pub fn segment_ends(&mut self) {
19✔
90
        self.segment_position_marks.displace();
19✔
91
        self.interpolated_positions.displace();
19✔
92
        self.segment_velocity_marks.displace_time();
19✔
93
        self.interpolated_velocities.displace_time();
19✔
94
    }
19✔
95

96
    pub fn num_segments(&self) -> usize {
1✔
97
        self.current_segment_id
1✔
98
    }
1✔
99

NEW
100
    pub fn current_segment_id(&self) -> usize {
×
NEW
101
        self.current_segment_id
×
NEW
102
    }
×
103

104
    pub fn micro_segment_ends(&mut self) {}
69✔
105

NEW
106
    pub fn current_micro_segment_id(&self) -> usize {
×
NEW
107
        self.current_micro_segment_id
×
NEW
108
    }
×
109

110
    pub fn total_displacement(&self) -> hwa::math::Real {
1✔
111
        self.total_displacement
1✔
112
    }
1✔
113

114
    pub fn interpolation_tick(
69✔
115
        &mut self,
69✔
116
        interp: &hwa::controllers::motion::SegmentIterator<control::motion::SCurveMotionProfile>,
69✔
117
    ) {
69✔
118
        self.interpolated_positions.push_relative(
69✔
119
            interp.current_time().to_f64(),
69✔
120
            interp.current_position().to_f64(),
69✔
121
        );
69✔
122
        self.interpolated_velocities.push_relative(
69✔
123
            interp.current_time().to_f64(),
69✔
124
            (interp.ds() / interp.dt()).to_f64(),
69✔
125
        )
69✔
126
    }
69✔
127
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc