Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic_graph_bridge
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
Stack Of Tasks
dynamic_graph_bridge
Commits
1ada8dde
Commit
1ada8dde
authored
8 years ago
by
Rohan Budhiraja
Browse files
Options
Downloads
Patches
Plain Diff
[c++][python] Move RosRobotModel from c++ to python
parent
cc6e0980
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
CMakeLists.txt
+1
-1
1 addition, 1 deletion
CMakeLists.txt
src/dynamic_graph/ros/__init__.py
+25
-3
25 additions, 3 deletions
src/dynamic_graph/ros/__init__.py
src/robot_model.cpp
+3
-16
3 additions, 16 deletions
src/robot_model.cpp
src/ros_joint_state.cpp
+10
-10
10 additions, 10 deletions
src/ros_joint_state.cpp
with
39 additions
and
30 deletions
CMakeLists.txt
+
1
−
1
View file @
1ada8dde
...
@@ -132,7 +132,7 @@ compile_plugin(ros_joint_state)
...
@@ -132,7 +132,7 @@ compile_plugin(ros_joint_state)
target_link_libraries
(
ros_joint_state
"
${
DYNAMIC_GRAPH_PLUGINDIR
}
/dynamic.so"
)
target_link_libraries
(
ros_joint_state
"
${
DYNAMIC_GRAPH_PLUGINDIR
}
/dynamic.so"
)
compile_plugin
(
robot_model
)
#
compile_plugin(robot_model)
# ros_interperter library.
# ros_interperter library.
add_library
(
ros_interpreter src/ros_interpreter.cpp
)
add_library
(
ros_interpreter src/ros_interpreter.cpp
)
...
...
This diff is collapsed.
Click to expand it.
src/dynamic_graph/ros/__init__.py
+
25
−
3
View file @
1ada8dde
from
dynamic_graph.sot.dynamics
import
Dynamic
from
ros_publish
import
RosPublish
from
ros_publish
import
RosPublish
from
ros_subscribe
import
RosSubscribe
from
ros_subscribe
import
RosSubscribe
from
ros_joint_state
import
RosJointState
from
ros_joint_state
import
RosJointState
from
robot_model
import
RosRobotModel
from
ros
import
Ros
from
ros
import
Ros
# aliases, for retro compatibility
# aliases, for retro compatibility
ros_import
=
ros_publish
ros_export
=
ros_subscribe
from
ros
import
RosPublish
as
RosImport
from
ros
import
RosPublish
as
RosImport
from
ros
import
RosSubscribe
as
RosExport
from
ros
import
RosSubscribe
as
RosExport
import
rospy
class
RosRobotModel
(
Dynamic
):
def
__init__
(
self
):
Dynamic
.
__init__
(
self
)
self
.
namespace
=
"
sot_controller
"
self
.
jointsParameterName_
=
"
jrl_map
"
def
setJointsNamesParameter
(
self
):
if
self
.
model
is
not
None
:
parameter_name
=
self
.
namespace
+
"
/
"
+
jointsParameterName_
jointsName
=
[]
for
i
in
xrange
(
self
.
model
.
njoints
):
jointsName
.
append
(
self
.
model
.
names
[
i
])
rospy
.
set_param
(
parameter_name
,
jointsName
)
return
def
setNamespace
(
self
,
ns
):
self
.
namespace
=
ns
return
def
curConf
(
self
):
return
self
.
position
.
value
This diff is collapsed.
Click to expand it.
src/robot_model.cpp
+
3
−
16
View file @
1ada8dde
...
@@ -58,13 +58,6 @@ RosRobotModel::~RosRobotModel()
...
@@ -58,13 +58,6 @@ RosRobotModel::~RosRobotModel()
void
RosRobotModel
::
loadUrdf
(
const
std
::
string
&
filename
)
void
RosRobotModel
::
loadUrdf
(
const
std
::
string
&
filename
)
{
{
// jrl::dynamics::urdf::Parser parser;
//TODO: Specific rep name. link them to the operational frames in pinocchio
// std::map<std::string, std::string>::const_iterator it = specialJoints_.begin();
// for (;it!=specialJoints_.end();++it) {
// parser.specifyREPName(it->first, it->second);
// }
rosInit
(
false
);
rosInit
(
false
);
m_model
=
se3
::
urdf
::
buildModel
(
filename
);
m_model
=
se3
::
urdf
::
buildModel
(
filename
);
this
->
m_urdfPath
=
filename
;
this
->
m_urdfPath
=
filename
;
...
@@ -89,13 +82,6 @@ void RosRobotModel::setNamespace (const std::string& ns)
...
@@ -89,13 +82,6 @@ void RosRobotModel::setNamespace (const std::string& ns)
void
RosRobotModel
::
loadFromParameterServer
()
void
RosRobotModel
::
loadFromParameterServer
()
{
{
//jrl::dynamics::urdf::Parser parser;
//TODO: Specific rep name. link them to the operational frames in pinocchio
// std::map<std::string, std::string>::const_iterator it = specialJoints_.begin();
// for (;it!=specialJoints_.end();++it) {
// parser.specifyREPName(it->first, it->second);
// }
rosInit
(
false
);
rosInit
(
false
);
std
::
string
robotDescription
;
std
::
string
robotDescription
;
ros
::
param
::
param
<
std
::
string
>
(
"/robot_description"
,
robotDescription
,
""
);
ros
::
param
::
param
<
std
::
string
>
(
"/robot_description"
,
robotDescription
,
""
);
...
@@ -119,7 +105,8 @@ void RosRobotModel::loadFromParameterServer()
...
@@ -119,7 +105,8 @@ void RosRobotModel::loadFromParameterServer()
XmlRpc
::
XmlRpcValue
JointsNamesByRank_
;
XmlRpc
::
XmlRpcValue
JointsNamesByRank_
;
JointsNamesByRank_
.
setSize
(
m_model
.
names
.
size
());
JointsNamesByRank_
.
setSize
(
m_model
.
names
.
size
());
std
::
vector
<
std
::
string
>::
const_iterator
it
=
m_model
.
names
.
begin
()
+
2
;
//first joint is universe, second is freeflyer
//first joint is universe, second is freeflyer
std
::
vector
<
std
::
string
>::
const_iterator
it
=
m_model
.
names
.
begin
()
+
2
;
for
(
int
i
=
0
;
it
!=
m_model
.
names
.
end
();
++
it
,
++
i
)
JointsNamesByRank_
[
i
]
=
(
*
it
);
for
(
int
i
=
0
;
it
!=
m_model
.
names
.
end
();
++
it
,
++
i
)
JointsNamesByRank_
[
i
]
=
(
*
it
);
nh
.
setParam
(
jointsParameterName_
,
JointsNamesByRank_
);
nh
.
setParam
(
jointsParameterName_
,
JointsNamesByRank_
);
}
}
...
@@ -151,7 +138,7 @@ Vector RosRobotModel::curConf() const
...
@@ -151,7 +138,7 @@ Vector RosRobotModel::curConf() const
throw
std
::
runtime_error
(
"no robot loaded"
);
throw
std
::
runtime_error
(
"no robot loaded"
);
else
{
else
{
//TODO: confirm accesscopy is for asynchronous commands
//TODO: confirm accesscopy is for asynchronous commands
Vector
currConf
=
jointPositionSIN
.
accessCopy
();
Vector
currConf
=
jointPositionSIN
.
accessCopy
();
for
(
int32_t
i
=
0
;
i
<
ffpose
.
size
();
++
i
)
for
(
int32_t
i
=
0
;
i
<
ffpose
.
size
();
++
i
)
currConf
(
i
)
=
static_cast
<
double
>
(
ffpose
[
i
]);
currConf
(
i
)
=
static_cast
<
double
>
(
ffpose
[
i
]);
...
...
This diff is collapsed.
Click to expand it.
src/ros_joint_state.cpp
+
10
−
10
View file @
1ada8dde
...
@@ -36,21 +36,21 @@ namespace dynamicgraph
...
@@ -36,21 +36,21 @@ namespace dynamicgraph
}
}
namespace
{
namespace
{
void
buildJointNames
(
sensor_msgs
::
JointState
&
jointState
,
se3
::
Model
&
robot_model
)
{
void
buildJointNames
(
sensor_msgs
::
JointState
&
jointState
,
se3
::
Model
*
robot_model
)
{
for
(
int
i
=
0
;
i
<
robot_model
.
nbody
-
1
;
i
++
)
{
for
(
int
i
=
0
;
i
<
robot_model
->
nbody
-
1
;
i
++
)
{
// Ignore anchors.
// Ignore anchors.
if
(
se3
::
nv
(
robot_model
.
joints
[
i
])
!=
0
)
{
if
(
se3
::
nv
(
robot_model
->
joints
[
i
])
!=
0
)
{
// If we only have one dof, the dof name is the joint name.
// If we only have one dof, the dof name is the joint name.
if
(
se3
::
nv
(
robot_model
.
joints
[
i
])
==
1
)
{
if
(
se3
::
nv
(
robot_model
->
joints
[
i
])
==
1
)
{
jointState
.
name
[
i
]
=
robot_model
.
names
[
i
];
jointState
.
name
[
i
]
=
robot_model
->
names
[
i
];
}
}
else
{
else
{
// ...otherwise, the dof name is the joint name on which
// ...otherwise, the dof name is the joint name on which
// the dof id is appended.
// the dof id is appended.
int
joint_dof
=
se3
::
nv
(
robot_model
.
joints
[
i
]);
int
joint_dof
=
se3
::
nv
(
robot_model
->
joints
[
i
]);
for
(
int
j
=
0
;
j
<
joint_dof
;
j
++
)
{
for
(
int
j
=
0
;
j
<
joint_dof
;
j
++
)
{
boost
::
format
fmt
(
"%1%_%2%"
);
boost
::
format
fmt
(
"%1%_%2%"
);
fmt
%
robot_model
.
names
[
i
];
fmt
%
robot_model
->
names
[
i
];
fmt
%
j
;
fmt
%
j
;
jointState
.
name
[
i
+
j
]
=
fmt
.
str
();
jointState
.
name
[
i
+
j
]
=
fmt
.
str
();
}
}
...
@@ -82,14 +82,14 @@ namespace dynamicgraph
...
@@ -82,14 +82,14 @@ namespace dynamicgraph
return
Value
();
return
Value
();
}
}
se3
::
Model
&
robot_model
=
dynamic
->
m_model
;
se3
::
Model
*
robot_model
=
dynamic
->
m_model
;
if
(
robot_model
.
nbody
==
1
)
if
(
robot_model
->
nbody
==
1
)
{
{
std
::
cerr
<<
"no robot in the dynamic entity"
<<
std
::
endl
;
std
::
cerr
<<
"no robot in the dynamic entity"
<<
std
::
endl
;
return
Value
();
return
Value
();
}
}
entity
.
jointState
().
name
.
resize
(
robot_model
.
nv
);
entity
.
jointState
().
name
.
resize
(
robot_model
->
nv
);
buildJointNames
(
entity
.
jointState
(),
robot_model
);
buildJointNames
(
entity
.
jointState
(),
robot_model
);
return
Value
();
return
Value
();
}
}
...
...
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