Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
darwin_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
darwin
darwin_robot_driver
Commits
75f9ea34
Commit
75f9ea34
authored
9 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added the necessary API to access the ADC module.
parent
b7d9ad23
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/darwin_robot.cpp
+66
-0
66 additions, 0 deletions
src/darwin_robot.cpp
src/darwin_robot.h
+12
-2
12 additions, 2 deletions
src/darwin_robot.h
src/examples/CMakeLists.txt
+5
-0
5 additions, 0 deletions
src/examples/CMakeLists.txt
with
83 additions
and
2 deletions
src/darwin_robot.cpp
+
66
−
0
View file @
75f9ea34
...
@@ -193,6 +193,72 @@ bool CDarwinRobot::is_button_pressed(pushbutton_t pushbutton)
...
@@ -193,6 +193,72 @@ bool CDarwinRobot::is_button_pressed(pushbutton_t pushbutton)
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
}
// ADC interface
void
CDarwinRobot
::
adc_enable
(
void
)
{
if
(
this
->
robot_device
!=
NULL
)
this
->
robot_device
->
write_byte_register
(
DARWIN_ADC_CNTRL
,
ADC_START
);
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
void
CDarwinRobot
::
adc_set_period
(
unsigned
char
period_ms
)
{
if
(
this
->
robot_device
!=
NULL
)
this
->
robot_device
->
write_byte_register
(
DARWIN_ADC_PERIOD
,
period_ms
);
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
double
CDarwinRobot
::
adc_get_value
(
adc_t
adc
)
{
unsigned
short
int
value
;
if
(
this
->
robot_device
!=
NULL
)
{
this
->
robot_device
->
read_word_register
(
DARWIN_ADC_CH1_L
+
((
int
)
adc
)
*
2
,
&
value
);
return
((
double
)
value
)
/
((
double
)(
1
<<
12
));
}
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
double
CDarwinRobot
::
adc_get_temperature
(
void
)
{
unsigned
short
int
value
;
if
(
this
->
robot_device
!=
NULL
)
{
this
->
robot_device
->
read_word_register
(
DARWIN_ADC_TEMP_L
,
&
value
);
return
((
double
)
value
)
/
((
double
)(
1
<<
10
));
}
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
double
CDarwinRobot
::
adc_get_vrefint
(
void
)
{
unsigned
short
int
value
;
if
(
this
->
robot_device
!=
NULL
)
{
this
->
robot_device
->
read_word_register
(
DARWIN_ADC_VREF_L
,
&
value
);
return
((
double
)
value
)
/
((
double
)(
1
<<
12
));
}
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
void
CDarwinRobot
::
adc_disable
(
void
)
{
if
(
this
->
robot_device
!=
NULL
)
this
->
robot_device
->
write_byte_register
(
DARWIN_ADC_CNTRL
,
ADC_STOP
);
else
throw
CDarwinRobotException
(
_HERE_
,
"Invalid robot device"
);
}
// motion manager interface
// motion manager interface
/*void CDarwinRobot::mm_set_period(double period_ms)
/*void CDarwinRobot::mm_set_period(double period_ms)
{
{
...
...
This diff is collapsed.
Click to expand it.
src/darwin_robot.h
+
12
−
2
View file @
75f9ea34
...
@@ -31,6 +31,11 @@ typedef struct
...
@@ -31,6 +31,11 @@ typedef struct
typedef
enum
{
START_PB
=
0
,
MODE_PB
=
1
}
pushbutton_t
;
typedef
enum
{
START_PB
=
0
,
MODE_PB
=
1
}
pushbutton_t
;
#define ADC_NUM_CHANNELS 16
typedef
enum
{
ADC_CH1
=
0
,
ADC_CH2
=
1
,
ADC_CH3
=
2
,
ADC_CH4
=
3
,
ADC_CH5
=
4
,
ADC_CH6
=
5
,
ADC_CH7
=
6
,
ADC_CH8
=
7
,
ADC_CH9
=
8
,
ADC_CH10
=
9
,
ADC_CH11
=
10
,
ADC_CH12
=
11
,
ADC_CH13
=
12
,
ADC_CH14
=
13
,
ADC_CH16
=
15
,
ADC_CH18
=
17
}
adc_t
;
class
CDarwinRobot
class
CDarwinRobot
{
{
private:
private:
...
@@ -50,6 +55,13 @@ class CDarwinRobot
...
@@ -50,6 +55,13 @@ class CDarwinRobot
void
gpio_aux1_color
(
double
red
,
double
green
,
double
blue
);
void
gpio_aux1_color
(
double
red
,
double
green
,
double
blue
);
void
gpio_aux2_color
(
double
red
,
double
green
,
double
blue
);
void
gpio_aux2_color
(
double
red
,
double
green
,
double
blue
);
bool
is_button_pressed
(
pushbutton_t
pushbutton
);
bool
is_button_pressed
(
pushbutton_t
pushbutton
);
// ADC interface
void
adc_enable
(
void
);
void
adc_set_period
(
unsigned
char
period_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
);
double
mm_get_period
(
void
);
double
mm_get_period
(
void
);
...
@@ -89,8 +101,6 @@ class CDarwinRobot
...
@@ -89,8 +101,6 @@ class CDarwinRobot
bool
imu_is_gyro_detected
(
void
);
bool
imu_is_gyro_detected
(
void
);
void
imu_get_accel_data
(
short
int
*
x
,
short
int
*
y
,
short
int
*
z
);
void
imu_get_accel_data
(
short
int
*
x
,
short
int
*
y
,
short
int
*
z
);
void
imu_get_gyro_data
(
short
int
*
x
,
short
int
*
y
,
short
int
*
z
);
void
imu_get_gyro_data
(
short
int
*
x
,
short
int
*
y
,
short
int
*
z
);
// adc interface
void
adc_get_data
(
void
);
// walking interface
// walking interface
void
walking_set_speeds
(
double
fw_step
,
double
side_step
,
double
turn
);
void
walking_set_speeds
(
double
fw_step
,
double
side_step
,
double
turn
);
void
walking_start
(
void
);
void
walking_start
(
void
);
...
...
This diff is collapsed.
Click to expand it.
src/examples/CMakeLists.txt
+
5
−
0
View file @
75f9ea34
...
@@ -8,6 +8,11 @@ ADD_EXECUTABLE(darwin_gpio_test darwin_gpio_test.cpp)
...
@@ -8,6 +8,11 @@ ADD_EXECUTABLE(darwin_gpio_test darwin_gpio_test.cpp)
# link necessary libraries
# link necessary libraries
TARGET_LINK_LIBRARIES
(
darwin_gpio_test darwin_robot
)
TARGET_LINK_LIBRARIES
(
darwin_gpio_test darwin_robot
)
# create an example application
ADD_EXECUTABLE
(
darwin_adc_test darwin_adc_test.cpp
)
# link necessary libraries
TARGET_LINK_LIBRARIES
(
darwin_adc_test darwin_robot
)
# create an example application
# create an example application
#ADD_EXECUTABLE(darwin_joint_motion_test darwin_joint_motion_test.cpp)
#ADD_EXECUTABLE(darwin_joint_motion_test darwin_joint_motion_test.cpp)
# link necessary libraries
# link necessary libraries
...
...
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