Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
bbb_bioloid_robot_driver
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
humanoides
bbb_bioloid_robot_driver
Commits
53c021c3
Commit
53c021c3
authored
10 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Implemented the action interface.
Added the necessary conversions to the IMU data.
parent
9a41fe04
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/bioloid_registers.h
+1
-1
1 addition, 1 deletion
src/bioloid_registers.h
src/bioloid_robot.cpp
+19
-7
19 additions, 7 deletions
src/bioloid_robot.cpp
src/examples/bioloid_robot_test.cpp
+44
-5
44 additions, 5 deletions
src/examples/bioloid_robot_test.cpp
with
64 additions
and
13 deletions
src/bioloid_registers.h
+
1
−
1
View file @
53c021c3
...
...
@@ -120,7 +120,7 @@ typedef enum {
BIOLOID_IMU_TEMP
=
0x80
,
BIOLOID_ACTION_PAGE
=
0x81
,
BIOLOID_ACTION_CONTROL
=
0x82
,
BIOLOID_ACTION_SATU
TU
S
=
0x83
BIOLOID_ACTION_S
T
ATUS
=
0x83
}
bioloid_registers
;
#endif
This diff is collapsed.
Click to expand it.
src/bioloid_robot.cpp
+
19
−
7
View file @
53c021c3
#include
"bioloid_robot.h"
#include
"bioloid_robot_exceptions.h"
#include
<iostream>
CBioloid_Robot
::
CBioloid_Robot
(
const
std
::
string
&
name
,
std
::
string
&
bus_id
,
int
bus_speed
,
unsigned
char
id
)
{
...
...
@@ -213,7 +214,7 @@ void CBioloid_Robot::mm_set_period(double period_ms)
unsigned
char
CBioloid_Robot
::
mm_get_num_servos
(
void
)
{
this
->
robot_device
->
read_byte_register
(
BIOLOID_
PUSHBUTTON
,
&
this
->
num_servos
);
this
->
robot_device
->
read_byte_register
(
BIOLOID_
MM_NUM_SERVOS
,
&
this
->
num_servos
);
return
this
->
num_servos
;
}
...
...
@@ -386,27 +387,38 @@ double CBioloid_Robot::mm_get_servo_angle(unsigned char servo_id)
// motion action interface
void
CBioloid_Robot
::
action_load_page
(
unsigned
char
page_id
)
{
this
->
robot_device
->
write_byte_register
(
BIOLOID_ACTION_PAGE
,
page_id
);
}
unsigned
char
CBioloid_Robot
::
action_get_current_page
(
void
)
{
unsigned
char
page_id
;
this
->
robot_device
->
read_byte_register
(
BIOLOID_ACTION_PAGE
,
&
page_id
);
return
page_id
;
}
void
CBioloid_Robot
::
action_start
(
void
)
{
this
->
robot_device
->
write_byte_register
(
BIOLOID_ACTION_CONTROL
,
0x01
);
}
void
CBioloid_Robot
::
action_stop
(
void
)
{
this
->
robot_device
->
write_byte_register
(
BIOLOID_ACTION_CONTROL
,
0x02
);
}
bool
CBioloid_Robot
::
action_is_page_running
(
void
)
{
unsigned
char
status
;
this
->
robot_device
->
read_byte_register
(
BIOLOID_ACTION_STATUS
,
&
status
);
std
::
cout
<<
std
::
hex
<<
(
int
)
status
<<
std
::
endl
;
if
(
status
&
0x01
)
return
true
;
else
return
false
;
}
// IMU interface
...
...
@@ -465,7 +477,7 @@ std::vector<double> CBioloid_Robot::imu_get_accel(void)
this
->
robot_device
->
read_registers
(
BIOLOID_IMU_ACCEL_X_L
,(
unsigned
char
*
)
values
,
6
);
for
(
i
=
0
;
i
<
3
;
i
++
)
accel
[
i
]
=
((
double
)
values
[
i
]);
accel
[
i
]
=
((
double
)
values
[
i
]
/
1000.0
);
return
accel
;
}
...
...
@@ -479,7 +491,7 @@ std::vector<double> CBioloid_Robot::imu_get_gyro(void)
this
->
robot_device
->
read_registers
(
BIOLOID_IMU_GYRO_X_L
,(
unsigned
char
*
)
values
,
6
);
for
(
i
=
0
;
i
<
3
;
i
++
)
gyro
[
i
]
=
((
double
)
values
[
i
]);
gyro
[
i
]
=
((
double
)
values
[
i
]
/
4.0
);
return
gyro
;
}
...
...
@@ -493,7 +505,7 @@ std::vector<double> CBioloid_Robot::imu_get_compass(void)
this
->
robot_device
->
read_registers
(
BIOLOID_IMU_COMPASS_X_L
,(
unsigned
char
*
)
values
,
6
);
for
(
i
=
0
;
i
<
3
;
i
++
)
compass
[
i
]
=
((
double
)
values
[
i
]);
compass
[
i
]
=
((
double
)
values
[
i
]
/
8192.0
);
return
compass
;
...
...
This diff is collapsed.
Click to expand it.
src/examples/bioloid_robot_test.cpp
+
44
−
5
View file @
53c021c3
...
...
@@ -7,16 +7,55 @@ std::string robot_device="A401293W";
int
main
(
int
argc
,
char
*
argv
[])
{
int
i
=
0
,
num_servos
,
count
=
0
;
std
::
vector
<
double
>
angles
,
accel
,
gyro
,
compass
;
try
{
CBioloid_Robot
tina
(
"Tina"
,
robot_device
,
115200
,
192
);
while
(
1
)
num_servos
=
tina
.
mm_get_num_servos
();
std
::
cout
<<
"Found "
<<
num_servos
<<
" servos"
<<
std
::
endl
;
// enable all servos and assign them to the action module
for
(
i
=
0
;
i
<
num_servos
;
i
++
)
{
tina
.
mm_enable_servo
(
i
);
tina
.
mm_assign_module
(
i
,
BIOLOID_MM_ACTION
);
}
tina
.
mm_start
();
tina
.
imu_enable
();
angles
=
tina
.
mm_get_servo_angles
();
for
(
i
=
0
;
i
<
num_servos
;
i
++
)
std
::
cout
<<
"Servo "
<<
i
<<
" angle: "
<<
angles
[
i
]
<<
std
::
endl
;
// execute an action
tina
.
action_load_page
(
2
);
tina
.
action_start
();
while
(
tina
.
action_is_page_running
())
{
usleep
(
100000
);
angles
=
tina
.
mm_get_servo_angles
();
for
(
i
=
0
;
i
<
num_servos
;
i
++
)
std
::
cout
<<
"Servo "
<<
i
<<
" angle: "
<<
angles
[
i
]
<<
std
::
endl
;
}
for
(
i
=
0
;
i
<
10
;
i
++
)
{
tina
.
set_manager_LED
();
sleep
(
1
);
tina
.
clear_manager_LED
();
sleep
(
1
);
accel
=
tina
.
imu_get_accel
();
gyro
=
tina
.
imu_get_gyro
();
compass
=
tina
.
imu_get_compass
();
std
::
cout
<<
"accel x: "
<<
accel
[
0
]
<<
std
::
endl
;
std
::
cout
<<
"accel y: "
<<
accel
[
1
]
<<
std
::
endl
;
std
::
cout
<<
"accel z: "
<<
accel
[
2
]
<<
std
::
endl
;
std
::
cout
<<
"gyro x: "
<<
gyro
[
0
]
<<
std
::
endl
;
std
::
cout
<<
"gyro y: "
<<
gyro
[
1
]
<<
std
::
endl
;
std
::
cout
<<
"gyro z: "
<<
gyro
[
2
]
<<
std
::
endl
;
std
::
cout
<<
"compass x: "
<<
compass
[
0
]
<<
std
::
endl
;
std
::
cout
<<
"compass y: "
<<
compass
[
1
]
<<
std
::
endl
;
std
::
cout
<<
"compass z: "
<<
compass
[
2
]
<<
std
::
endl
;
usleep
(
100000
);
}
tina
.
imu_disable
();
tina
.
mm_stop
();
}
catch
(
CException
&
e
){
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
}
...
...
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