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
a399349a
Commit
a399349a
authored
9 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added support for the ADC converter.
parent
2ea23ed4
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_robot.cpp
+57
-0
57 additions, 0 deletions
src/bioloid_robot.cpp
src/bioloid_robot.h
+9
-0
9 additions, 0 deletions
src/bioloid_robot.h
src/examples/bioloid_robot_test.cpp
+12
-15
12 additions, 15 deletions
src/examples/bioloid_robot_test.cpp
with
78 additions
and
15 deletions
src/bioloid_robot.cpp
+
57
−
0
View file @
a399349a
...
@@ -197,6 +197,63 @@ bool CBioloidRobot::is_button_pressed(pushbutton_t pushbutton)
...
@@ -197,6 +197,63 @@ bool CBioloidRobot::is_button_pressed(pushbutton_t pushbutton)
return
false
;
return
false
;
}
}
// ADC interface
void
CBioloidRobot
::
adc_enable
(
void
)
{
}
void
CBioloidRobot
::
adc_set_period
(
unsigned
char
perios_ms
)
{
}
double
CBioloidRobot
::
adc_get_value
(
adc_t
adc
)
{
unsigned
short
int
value
;
switch
(
adc
)
{
case
ADC_CH1
:
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_CH1_L
,
&
value
);
break
;
case
ADC_CH2
:
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_CH2_L
,
&
value
);
break
;
case
ADC_CH3
:
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_CH3_L
,
&
value
);
break
;
case
ADC_CH4
:
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_CH4_L
,
&
value
);
break
;
case
ADC_CH5
:
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_CH6_L
,
&
value
);
break
;
case
ADC_CH6
:
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_CH8_L
,
&
value
);
break
;
}
return
((
double
)
value
)
/
((
double
)(
1
<<
12
));
}
double
CBioloidRobot
::
adc_get_temperature
(
void
)
{
unsigned
short
int
value
;
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_TEMP_L
,
&
value
);
return
((
double
)
value
)
/
((
double
)(
1
<<
10
));
}
double
CBioloidRobot
::
adc_get_vrefint
(
void
)
{
unsigned
short
int
value
;
this
->
robot_device
->
read_word_register
(
BIOLOID_ADC_VREF_L
,
&
value
);
return
((
double
)
value
)
/
((
double
)(
1
<<
12
));
}
void
CBioloidRobot
::
adc_disable
(
void
)
{
}
// motion manager interface
// motion manager interface
/*void CBioloidRobot::mm_set_period(double period_ms)
/*void CBioloidRobot::mm_set_period(double period_ms)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/bioloid_robot.h
+
9
−
0
View file @
a399349a
...
@@ -16,6 +16,8 @@ typedef enum {BIOLOD_MM_NONE=0x00,BIOLOID_MM_ACTION=0x01,BIOLOID_MM_WALKING=0x02
...
@@ -16,6 +16,8 @@ typedef enum {BIOLOD_MM_NONE=0x00,BIOLOID_MM_ACTION=0x01,BIOLOID_MM_WALKING=0x02
typedef
enum
{
USER1_LED
,
USER2_LED
,
RXD_LED
,
TXD_LED
}
led_t
;
typedef
enum
{
USER1_LED
,
USER2_LED
,
RXD_LED
,
TXD_LED
}
led_t
;
/* available pushbuttons */
/* available pushbuttons */
typedef
enum
{
USER_PB
,
RESET_PB
,
START_PB
,
MODE_PB
}
pushbutton_t
;
typedef
enum
{
USER_PB
,
RESET_PB
,
START_PB
,
MODE_PB
}
pushbutton_t
;
/* available ADC channels */
typedef
enum
{
ADC_CH1
,
ADC_CH2
,
ADC_CH3
,
ADC_CH4
,
ADC_CH5
,
ADC_CH6
}
adc_t
;
class
CBioloidRobot
class
CBioloidRobot
{
{
...
@@ -109,6 +111,13 @@ class CBioloidRobot
...
@@ -109,6 +111,13 @@ class CBioloidRobot
break
;
break
;
}
}
}
}
// ADC interface
void
adc_enable
(
void
);
void
adc_set_period
(
unsigned
char
perios_ms
);
double
adc_get_value
(
adc_t
adc
);
double
adc_get_temperature
(
void
);
double
adc_get_vrefint
(
void
);
void
adc_disable
(
void
);
// motion manager interface
// motion manager interface
/* void mm_set_period(double period_ms);
/* void mm_set_period(double period_ms);
unsigned char mm_get_num_servos(void);
unsigned char mm_get_num_servos(void);
...
...
This diff is collapsed.
Click to expand it.
src/examples/bioloid_robot_test.cpp
+
12
−
15
View file @
a399349a
...
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
...
@@ -35,7 +35,7 @@ int main(int argc, char *argv[])
try
{
try
{
CBioloidRobot
tina
(
"Tina"
,
robot_device
,
921600
,
0x02
,
GPIO2
,
25
);
CBioloidRobot
tina
(
"Tina"
,
robot_device
,
921600
,
0x02
,
GPIO2
,
25
);
tina
.
assign_button_callback
(
USER_PB
,
&
callbacks
,
&
CCallbacks
::
user_pb_callback
);
/*
tina.assign_button_callback(USER_PB,&callbacks,&CCallbacks::user_pb_callback);
tina.assign_button_callback(RESET_PB,&callbacks,&CCallbacks::reset_pb_callback);
tina.assign_button_callback(RESET_PB,&callbacks,&CCallbacks::reset_pb_callback);
tina.assign_button_callback(START_PB,&callbacks,&CCallbacks::start_pb_callback);
tina.assign_button_callback(START_PB,&callbacks,&CCallbacks::start_pb_callback);
tina.assign_button_callback(MODE_PB,&callbacks,&CCallbacks::mode_pb_callback);
tina.assign_button_callback(MODE_PB,&callbacks,&CCallbacks::mode_pb_callback);
...
@@ -62,22 +62,19 @@ int main(int argc, char *argv[])
...
@@ -62,22 +62,19 @@ int main(int argc, char *argv[])
tina.clear_led(TXD_LED);
tina.clear_led(TXD_LED);
tina.clear_led(USER1_LED);
tina.clear_led(USER1_LED);
tina.clear_led(USER2_LED);
tina.clear_led(USER2_LED);
sleep
(
10
);
sleep(10);
*/
/*
for(i=0;i<100;i++)
for
(
i
=
0
;
i
<
100
;
i
++
)
{
{
if(tina.is_button_pressed(RESET_PB))
std
::
cout
<<
"temperature: "
<<
tina
.
adc_get_temperature
()
<<
std
::
endl
;
std::cout << "Reset button pressed" << std::endl;
std
::
cout
<<
"Vref_int: "
<<
tina
.
adc_get_vrefint
()
<<
std
::
endl
;
else
std
::
cout
<<
"Channel 1: "
<<
tina
.
adc_get_value
(
ADC_CH1
)
<<
std
::
endl
;
std::cout << "Reset button not pressed" << std::endl;
std
::
cout
<<
"Channel 2: "
<<
tina
.
adc_get_value
(
ADC_CH2
)
<<
std
::
endl
;
std
::
cout
<<
"Channel 3: "
<<
tina
.
adc_get_value
(
ADC_CH3
)
<<
std
::
endl
;
std
::
cout
<<
"Channel 4: "
<<
tina
.
adc_get_value
(
ADC_CH4
)
<<
std
::
endl
;
std
::
cout
<<
"Channel 5: "
<<
tina
.
adc_get_value
(
ADC_CH5
)
<<
std
::
endl
;
std
::
cout
<<
"Channel 6: "
<<
tina
.
adc_get_value
(
ADC_CH6
)
<<
std
::
endl
;
usleep
(
100000
);
usleep
(
100000
);
}*/
}
// tina.clear_led(USER1_LED);
/* for(i=0;i<10;i++)
{
std::cout << "toggle led" << std::endl;
tina.toggle_led(USER1_LED);
sleep(1);
}*/
}
catch
(
CException
&
e
){
}
catch
(
CException
&
e
){
std
::
cout
<<
e
.
what
()
<<
std
::
endl
;
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