Skip to content

Commit 751b7fb

Browse files
committed
Merge branch 'main' of ssh://github.com/viamrobotics/rust-utils into dependabot/cargo/tracing-subscriber-0.3.20
2 parents b0f0ddb + f81c214 commit 751b7fb

File tree

3 files changed

+32
-27
lines changed

3 files changed

+32
-27
lines changed

src/ffi/spatialmath/orientation_vector.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ pub unsafe extern "C" fn orientation_vector_get_components(
6969
) -> *const c_double {
7070
null_pointer_check!(ov_ptr);
7171
let components: [c_double; 4] = [
72-
(*ov_ptr).o_vector.x,
73-
(*ov_ptr).o_vector.y,
74-
(*ov_ptr).o_vector.z,
75-
(*ov_ptr).theta,
72+
(&(*ov_ptr)).o_vector.x,
73+
(&(*ov_ptr)).o_vector.y,
74+
(&(*ov_ptr)).o_vector.z,
75+
(&(*ov_ptr)).theta,
7676
];
7777
Box::into_raw(Box::new(components)) as *const _
7878
}
@@ -98,7 +98,7 @@ pub unsafe extern "C" fn orientation_vector_from_quaternion(
9898
///
9999
/// # Safety
100100
///
101-
/// Outer processes that request the components of a orientation vector should call this function
101+
/// Outer processes that request the components of a orientation vector should call this function
102102
/// to free the memory allocated to the array once finished
103103
#[no_mangle]
104104
pub unsafe extern "C" fn free_orientation_vector_components(ptr: *mut c_double) {

src/ffi/spatialmath/quaternion.rs

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,9 @@ pub unsafe extern "C" fn new_quaternion_from_vector(
4949
null_pointer_check!(imag_ptr);
5050
to_raw_pointer(&Quaternion::new(
5151
real,
52-
(*imag_ptr).x,
53-
(*imag_ptr).y,
54-
(*imag_ptr).z,
52+
(&(*imag_ptr)).x,
53+
(&(*imag_ptr)).y,
54+
(&(*imag_ptr)).z,
5555
))
5656
}
5757

@@ -82,7 +82,12 @@ pub unsafe extern "C" fn quaternion_get_components(
8282
quat_ptr: *const Quaternion<f64>,
8383
) -> *const c_double {
8484
null_pointer_check!(quat_ptr);
85-
let components: [c_double; 4] = [(*quat_ptr).w, (*quat_ptr).i, (*quat_ptr).j, (*quat_ptr).k];
85+
let components: [c_double; 4] = [
86+
(&(*quat_ptr)).w,
87+
(&(*quat_ptr)).i,
88+
(&(*quat_ptr)).j,
89+
(&(*quat_ptr)).k,
90+
];
8691
Box::into_raw(Box::new(components)) as *const _
8792
}
8893

@@ -97,7 +102,7 @@ pub unsafe extern "C" fn quaternion_get_components(
97102
#[no_mangle]
98103
pub unsafe extern "C" fn quaternion_set_real(quat_ptr: *mut Quaternion<f64>, real: f64) {
99104
null_pointer_check!(quat_ptr);
100-
(*quat_ptr).w = real;
105+
(&mut (*quat_ptr)).w = real;
101106
}
102107

103108
/// Set the i component of an existing quaternion stored at the address
@@ -111,7 +116,7 @@ pub unsafe extern "C" fn quaternion_set_real(quat_ptr: *mut Quaternion<f64>, rea
111116
#[no_mangle]
112117
pub unsafe extern "C" fn quaternion_set_i(quat_ptr: *mut Quaternion<f64>, i: f64) {
113118
null_pointer_check!(quat_ptr);
114-
(*quat_ptr).i = i;
119+
(&mut (*quat_ptr)).i = i;
115120
}
116121

117122
/// Set the j component of an existing quaternion stored at the address
@@ -125,7 +130,7 @@ pub unsafe extern "C" fn quaternion_set_i(quat_ptr: *mut Quaternion<f64>, i: f64
125130
#[no_mangle]
126131
pub unsafe extern "C" fn quaternion_set_j(quat_ptr: *mut Quaternion<f64>, j: f64) {
127132
null_pointer_check!(quat_ptr);
128-
(*quat_ptr).j = j;
133+
(&mut (*quat_ptr)).j = j;
129134
}
130135

131136
/// Set the k component of an existing quaternion stored at the address
@@ -139,7 +144,7 @@ pub unsafe extern "C" fn quaternion_set_j(quat_ptr: *mut Quaternion<f64>, j: f64
139144
#[no_mangle]
140145
pub unsafe extern "C" fn quaternion_set_k(quat_ptr: *mut Quaternion<f64>, k: f64) {
141146
null_pointer_check!(quat_ptr);
142-
(*quat_ptr).k = k;
147+
(&mut (*quat_ptr)).k = k;
143148
}
144149

145150
/// Set all of the components of an existing quaternion stored at the address
@@ -159,10 +164,10 @@ pub unsafe extern "C" fn quaternion_set_components(
159164
k: f64,
160165
) {
161166
null_pointer_check!(quat_ptr);
162-
(*quat_ptr).w = real;
163-
(*quat_ptr).i = i;
164-
(*quat_ptr).j = j;
165-
(*quat_ptr).k = k;
167+
(&mut (*quat_ptr)).w = real;
168+
(&mut (*quat_ptr)).i = i;
169+
(&mut (*quat_ptr)).j = j;
170+
(&mut (*quat_ptr)).k = k;
166171
}
167172

168173
/// Set the imaginary components of an existing quaternion stored at
@@ -182,9 +187,9 @@ pub unsafe extern "C" fn quaternion_set_imag_from_vector(
182187
) {
183188
null_pointer_check!(quat_ptr);
184189
null_pointer_check!(vec_ptr);
185-
(*quat_ptr).i = (*vec_ptr).x;
186-
(*quat_ptr).j = (*vec_ptr).y;
187-
(*quat_ptr).k = (*vec_ptr).z;
190+
(&mut (*quat_ptr)).i = (&(*vec_ptr)).x;
191+
(&mut (*quat_ptr)).j = (&(*vec_ptr)).y;
192+
(&mut (*quat_ptr)).k = (&(*vec_ptr)).z;
188193
}
189194

190195
/// Copies the imaginary components to a 3-vector (using x -> i, y -> j
@@ -272,7 +277,7 @@ pub unsafe extern "C" fn quaternion_from_euler_angles(
272277
) -> *mut Quaternion<f64> {
273278
let unit_quat = UnitQuaternion::from_euler_angles(roll, pitch, yaw);
274279
let quat = unit_quat.quaternion();
275-
to_raw_pointer(&quat)
280+
to_raw_pointer(quat)
276281
}
277282

278283
/// Converts from an axis angle given by a vector's x, y, z components
@@ -453,7 +458,7 @@ pub unsafe extern "C" fn quaternion_hamiltonian_product(
453458
///
454459
/// # Safety
455460
///
456-
/// Outer processes that request the components of a quaternion should call this function
461+
/// Outer processes that request the components of a quaternion should call this function
457462
/// to free the memory allocated to the array once finished
458463
#[no_mangle]
459464
pub unsafe extern "C" fn free_quaternion_components(ptr: *mut c_double) {

src/ffi/spatialmath/vector3.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub unsafe extern "C" fn free_vector_memory(ptr: *mut Vector3<f64>) {
5050
#[no_mangle]
5151
pub unsafe extern "C" fn vector_get_components(vec_ptr: *const Vector3<f64>) -> *const c_double {
5252
null_pointer_check!(vec_ptr);
53-
let components: [c_double; 3] = [(*vec_ptr)[0], (*vec_ptr)[1], (*vec_ptr)[2]];
53+
let components: [c_double; 3] = [(&(*vec_ptr))[0], (&(*vec_ptr))[1], (&(*vec_ptr))[2]];
5454
Box::into_raw(Box::new(components)) as *const _
5555
}
5656

@@ -64,7 +64,7 @@ pub unsafe extern "C" fn vector_get_components(vec_ptr: *const Vector3<f64>) ->
6464
#[no_mangle]
6565
pub unsafe extern "C" fn vector_set_x(vec_ptr: *mut Vector3<f64>, x_val: f64) {
6666
null_pointer_check!(vec_ptr);
67-
(*vec_ptr)[0] = x_val;
67+
(&mut (*vec_ptr))[0] = x_val;
6868
}
6969

7070
/// Set the y component of an existing vector stored at the address
@@ -77,7 +77,7 @@ pub unsafe extern "C" fn vector_set_x(vec_ptr: *mut Vector3<f64>, x_val: f64) {
7777
#[no_mangle]
7878
pub unsafe extern "C" fn vector_set_y(vec_ptr: *mut Vector3<f64>, y_val: f64) {
7979
null_pointer_check!(vec_ptr);
80-
(*vec_ptr)[1] = y_val;
80+
(&mut (*vec_ptr))[1] = y_val;
8181
}
8282

8383
/// Set the z component of an existing vector stored at the address
@@ -90,7 +90,7 @@ pub unsafe extern "C" fn vector_set_y(vec_ptr: *mut Vector3<f64>, y_val: f64) {
9090
#[no_mangle]
9191
pub unsafe extern "C" fn vector_set_z(vec_ptr: *mut Vector3<f64>, z_val: f64) {
9292
null_pointer_check!(vec_ptr);
93-
(*vec_ptr)[2] = z_val;
93+
(&mut (*vec_ptr))[2] = z_val;
9494
}
9595

9696
/// Normalizes an existing vector stored at the address of
@@ -224,7 +224,7 @@ pub unsafe extern "C" fn vector_cross_product(
224224
///
225225
/// # Safety
226226
///
227-
/// Outer processes that request the components of a vector should call this function
227+
/// Outer processes that request the components of a vector should call this function
228228
/// to free the memory allocated to the array once finished
229229
#[no_mangle]
230230
pub unsafe extern "C" fn free_vector_components(ptr: *mut c_double) {

0 commit comments

Comments
 (0)