Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
labrobotica
drivers
bno055_imu_driver
Commits
3bdf2415
Commit
3bdf2415
authored
Jun 08, 2021
by
Sergi Hernandez
Browse files
Added a function to set the units of the sensor (accelerations and angular speeds).
parent
f863e499
Changes
2
Hide whitespace changes
Inline
Side-by-side
include/bno055_imu_driver.h
View file @
3bdf2415
...
...
@@ -83,6 +83,7 @@ class CBNO055IMUDriver
void
get_remap_axis
(
std
::
vector
<
char
>
&
new_x
,
std
::
vector
<
char
>
&
new_y
,
std
::
vector
<
char
>
&
new_z
);
void
set_data_rate
(
double
rate_hz
);
double
get_data_rate
(
void
);
void
set_sensor_units
(
bool
degrees_s
,
bool
m_s_s
);
std
::
string
get_new_data_event_id
(
void
);
/* accelerometer functions */
std
::
vector
<
double
>
get_raw_accelerometer
(
void
);
...
...
src/bno055_imu_driver.cpp
View file @
3bdf2415
...
...
@@ -524,6 +524,43 @@ void CBNO055IMUDriver::get_sensor_units(void)
}
}
void
CBNO055IMUDriver
::
set_sensor_units
(
bool
degrees_s
,
bool
m_s_s
)
{
unsigned
char
units
=
0x00
;
try
{
if
(
m_s_s
)
{
units
&=
0xFE
;
this
->
accel_config
.
units
=
accel_linear
;
}
else
{
units
|=
0x01
;
this
->
accel_config
.
units
=
accel_gravity
;
}
if
(
degrees_s
)
{
units
&=
0xF9
;
this
->
gyro_config
.
units
=
gyro_deg
;
this
->
euler_units
=
euler_deg
;
}
else
{
units
|=
0x06
;
this
->
gyro_config
.
units
=
gyro_rad
;
this
->
euler_units
=
euler_rad
;
}
this
->
imu_access
.
enter
();
this
->
change_register_page
(
0x00
);
this
->
write_registers
(
0x3B
,
1
,
&
units
);
this
->
imu_access
.
exit
();
}
catch
(
CException
&
e
){
this
->
imu_access
.
exit
();
throw
;
}
}
void
CBNO055IMUDriver
::
get_sensor_configs
(
void
)
{
unsigned
char
configs
[
4
];
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment