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
61a5f3e5
Commit
61a5f3e5
authored
5 years ago
by
Sergi Hernandez
Browse files
Options
Downloads
Patches
Plain Diff
Added a module to interface with the ADC.
parent
c1959c56
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
include/darwin_adc.h
+26
-0
26 additions, 0 deletions
include/darwin_adc.h
include/darwin_registers.h
+23
-0
23 additions, 0 deletions
include/darwin_registers.h
src/CMakeLists.txt
+3
-3
3 additions, 3 deletions
src/CMakeLists.txt
src/darwin_adc.cpp
+62
-0
62 additions, 0 deletions
src/darwin_adc.cpp
with
114 additions
and
3 deletions
include/darwin_adc.h
0 → 100644
+
26
−
0
View file @
61a5f3e5
#ifndef _DARWIN_ADC_H
#define _DARWIN_ADC_H
#include
"darwin_robot_base.h"
#include
"darwin_registers.h"
#define ADC_NUM_CHANNELS 12
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_CH12
=
11
}
adc_t
;
class
CDarwinADC
:
public
CDarwinRobotBase
{
public:
CDarwinADC
(
const
std
::
string
&
name
,
std
::
string
&
bus_id
,
int
bus_speed
,
unsigned
char
id
);
// ADC interface
void
start
(
void
);
bool
is_running
(
void
);
void
set_period
(
unsigned
char
period_ms
);
double
get_value
(
adc_t
adc
);
double
get_temperature
(
void
);
void
stop
(
void
);
~
CDarwinADC
();
};
#endif
This diff is collapsed.
Click to expand it.
include/darwin_registers.h
+
23
−
0
View file @
61a5f3e5
...
@@ -8,6 +8,9 @@
...
@@ -8,6 +8,9 @@
#define MANAGER_START 0x01
#define MANAGER_START 0x01
#define MANAGER_STOP 0x02
#define MANAGER_STOP 0x02
#define MANAGER_START_SCAN 0x04
#define MANAGER_START_SCAN 0x04
#define MANAGER_ENABLE_POWER 0x08
#define MANAGER_DISABLE_POWER 0x10
#define MANAGER_POWERED 0x20
#define MANAGER_RUNNING 0x40
#define MANAGER_RUNNING 0x40
#define MANAGER_SCANNING 0x80
#define MANAGER_SCANNING 0x80
#define MANAGER_NUM_DEVICES 131
#define MANAGER_NUM_DEVICES 131
...
@@ -138,5 +141,25 @@
...
@@ -138,5 +141,25 @@
#define BALANCE_ANKLE_PITCH_GAIN_OFFSET 11
#define BALANCE_ANKLE_PITCH_GAIN_OFFSET 11
#define BALANCE_HIP_ROLL_GAIN_OFFSET 13
#define BALANCE_HIP_ROLL_GAIN_OFFSET 13
#define ADC_PERIOD_OFFSET 15
#define ADC_CONTROL_OFFSET 403// bit 7 | bit 6 | bit 5 | bit 4 | bit 3 | bit 2 | bit 1 | bit 0
// | | | running | | | stop | start
#define ADC_START 0x01
#define ADC_STOP 0x02
#define ADC_RUNNING 0x10
#define ADC_CH1_VOLTAGE_OFFSET 404
#define ADC_CH2_VOLTAGE_OFFSET 406
#define ADC_CH3_VOLTAGE_OFFSET 408
#define ADC_CH4_VOLTAGE_OFFSET 410
#define ADC_CH5_VOLTAGE_OFFSET 412
#define ADC_CH6_VOLTAGE_OFFSET 414
#define ADC_CH7_VOLTAGE_OFFSET 416
#define ADC_CH8_VOLTAGE_OFFSET 418
#define ADC_CH9_VOLTAGE_OFFSET 420
#define ADC_CH10_VOLTAGE_OFFSET 422
#define ADC_TEMP_OFFSET 424
#define ADC_CH12_VOLTAGE_OFFSET 426
#endif
#endif
This diff is collapsed.
Click to expand it.
src/CMakeLists.txt
+
3
−
3
View file @
61a5f3e5
...
@@ -11,9 +11,9 @@ SET(KDL_INSTALL /opt/ros/indigo)
...
@@ -11,9 +11,9 @@ SET(KDL_INSTALL /opt/ros/indigo)
INCLUDE
(
${
PROJECT_SOURCE_DIR
}
/FindKDL.cmake
)
INCLUDE
(
${
PROJECT_SOURCE_DIR
}
/FindKDL.cmake
)
# driver source files
# driver source files
SET
(
robot_sources darwin_robot_base.cpp darwin_robot_exceptions.cpp darwin_imu.cpp darwin_dyn_manager.cpp darwin_mmanager.cpp darwin_action.cpp darwin_balance.cpp darwin_joint_motion.cpp darwin_walk.cpp darwin_head_tracking.cpp
)
SET
(
robot_sources darwin_robot_base.cpp darwin_robot_exceptions.cpp darwin_imu.cpp darwin_dyn_manager.cpp darwin_mmanager.cpp darwin_action.cpp darwin_balance.cpp darwin_joint_motion.cpp darwin_walk.cpp darwin_head_tracking.cpp
darwin_adc.cpp
)
# application header files
# application header files
SET
(
robot_headers ../include/darwin_robot_base.h ../include/darwin_robot_exceptions.h ../include/darwin_imu.h ../include/darwin_dyn_manager.h ../include/darwin_mmanager.h ../include/darwin_action.h ../include/darwin_balance.h ../include/darwin_joint_motion.h ../include/darwin_walk.h ../include/darwin_head_tracking.h
)
SET
(
robot_headers ../include/darwin_robot_base.h ../include/darwin_robot_exceptions.h ../include/darwin_imu.h ../include/darwin_dyn_manager.h ../include/darwin_mmanager.h ../include/darwin_action.h ../include/darwin_balance.h ../include/darwin_joint_motion.h ../include/darwin_walk.h ../include/darwin_head_tracking.h
../include/darwin_adc.h
)
# locate the necessary dependencies
# locate the necessary dependencies
FIND_PACKAGE
(
iriutils REQUIRED
)
FIND_PACKAGE
(
iriutils REQUIRED
)
...
@@ -35,7 +35,7 @@ IF(EIGEN3_FOUND)
...
@@ -35,7 +35,7 @@ IF(EIGEN3_FOUND)
SET
(
kin_leg_headers ../include/darwin_leg_kinematics.h ../include/darwin_robot_exceptions.h
)
SET
(
kin_leg_headers ../include/darwin_leg_kinematics.h ../include/darwin_robot_exceptions.h
)
ENDIF
(
EIGEN3_FOUND
)
ENDIF
(
EIGEN3_FOUND
)
#
ADD_DEFINITIONS(-D_SIM)
ADD_DEFINITIONS
(
-D_SIM
)
# add the necessary include directories
# add the necessary include directories
INCLUDE_DIRECTORIES
(
../include
)
INCLUDE_DIRECTORIES
(
../include
)
...
...
This diff is collapsed.
Click to expand it.
src/darwin_adc.cpp
0 → 100644
+
62
−
0
View file @
61a5f3e5
#include
"darwin_adc.h"
#include
"darwin_robot_exceptions.h"
CDarwinADC
::
CDarwinADC
(
const
std
::
string
&
name
,
std
::
string
&
bus_id
,
int
bus_speed
,
unsigned
char
id
)
:
CDarwinRobotBase
(
name
,
bus_id
,
bus_speed
,
id
)
{
}
// ADC interface
void
CDarwinADC
::
start
(
void
)
{
this
->
is_valid
();
this
->
robot_device
->
write_byte_register
(
ADC_CONTROL_OFFSET
,
ADC_START
);
}
bool
CDarwinADC
::
is_running
(
void
)
{
unsigned
char
status
;
this
->
is_valid
();
this
->
robot_device
->
read_byte_register
(
ADC_CONTROL_OFFSET
,
&
status
);
if
(
status
&
ADC_RUNNING
)
return
true
;
else
return
false
;
}
void
CDarwinADC
::
set_period
(
unsigned
char
period_ms
)
{
this
->
is_valid
();
this
->
robot_device
->
write_byte_register
(
ADC_PERIOD_OFFSET
,
period_ms
);
}
double
CDarwinADC
::
get_value
(
adc_t
adc
)
{
unsigned
short
int
value
;
this
->
is_valid
();
this
->
robot_device
->
read_word_register
(
ADC_CH1_VOLTAGE_OFFSET
+
((
int
)
adc
)
*
2
,
&
value
);
return
((
double
)
value
)
/
((
double
)(
1
<<
12
));
}
double
CDarwinADC
::
get_temperature
(
void
)
{
unsigned
short
int
value
;
this
->
is_valid
();
this
->
robot_device
->
read_word_register
(
ADC_TEMP_OFFSET
,
&
value
);
return
((
double
)
value
)
/
((
double
)(
1
<<
10
));
}
void
CDarwinADC
::
stop
(
void
)
{
this
->
is_valid
();
this
->
robot_device
->
write_byte_register
(
ADC_CONTROL_OFFSET
,
ADC_STOP
);
}
CDarwinADC
::~
CDarwinADC
()
{
}
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