Use Pygazebo with Link class to set Link position/linear velocity?
I am trying to use pygazebo to control the position of links, which I thought was possible based on the attributes of the link class (as listed here https://media.readthedocs.org/pdf/pygazebo/latest/pygazebo.pdf). However, I am getting the error:
AttributeError: 'Assignment not allowed to composite field "pose" in protocol message object.'
Initally I thought to use message.pose.target (as one uses with Joint_CMD) but this did not work. Any advice?
Asked by pj on 2018-05-31 10:00:46 UTC
Answers
i think that you used joint_cmd_pb2 that control joints not links https://github.com/jpieper/pygazebo/blob/develop/pygazebo/msg/joint_cmd_pb2.py i foubd that he have another file for links : https://github.com/jpieper/pygazebo/blob/develop/pygazebo/msg/link_pb2.py i think that you can use it and i saw that it use : linear_velocity , angular_velocity
at lines no. 82 , 83 :
_LINKDATA.fields_by_name['linear_velocity'].message_type = vector3d_pb2._VECTOR3D _LINKDATA.fields_by_name['angular_velocity'].message_type = vector3d_pb2._VECTOR3D
There is a nice example can hep you to understand the joints and move it by the keyboard ;) I am working on a task to move a link by the keyboard and i found that this example is helpfull .
if you like to tryit
1-it is the world file that have the map of the keys that you can test : https://bitbucket.org/osrf/gazebo/src/f4e51e8f64001beda70615ab8982a7d5a4e65b18/worlds/simple_arm_teleop.world
2-you will need this files too KeyboardGUIPlugin.cc , KeyboardGUIPlugin.hh , KeysToJointsPlugin.cc , KeysToJointsPlugin.hh download it from :
https://bitbucket.org/osrf/gazebo/src/20ec72b144b00a689d642f9eb3dbcf92878e4ff8/plugins/KeysToJointsPlugin.cc https://bitbucket.org/osrf/gazebo/src/20ec72b144b00a689d642f9eb3dbcf92878e4ff8/plugins/KeysToJointsPlugin.hh https://bitbucket.org/osrf/gazebo/src/20ec72b144b00a689d642f9eb3dbcf92878e4ff8/plugins/KeyboardGUIPlugin.cc https://bitbucket.org/osrf/gazebo/src/20ec72b144b00a689d642f9eb3dbcf92878e4ff8/plugins/KeyboardGUIPlugin.hh
The documentation of those files. http://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/classgazebo_1_1KeyboardGUIPlugin.html http://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/classgazebo_1_1KeysToJointsPlugin.html
3- last 2 things , you need to write the CMakeLists.txt as :
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
find_package (Qt5Core REQUIRED) find_package (Qt5Widgets REQUIRED) set (CMAKE_AUTOMOC ON)
find_package(gazebo REQUIRED) include_directories(${GAZEBO_INCLUDE_DIRS}) link_directories(${GAZEBO_LIBRARY_DIRS}) list(APPEND CMAKE_CXX_FLAGS "${GAZEBO_CXX_FLAGS}")
add_library(KeyboardGUIPlugin MODULE KeyboardGUIPlugin.cc) target_link_libraries(KeyboardGUIPlugina ${GAZEBO_LIBRARIES} Qt5::Core)
add_library(KeysToJointsPlugin MODULE KeysToJointsPlugin.cc) target_link_libraries(KeysToJointsPlugina ${GAZEBO_LIBRARIES} Qt5::Core)
4-Then :
mkdir build
cd build
cmake ../
make
export GAZEBO_PLUGIN_PATH=pwd
:$GAZEBO_PLUGIN_PATH
gazebo -u --verbose ../simple_arm_teleop.world
press 6,h,y,u,j,i,k and see ;)
i found that KeysToJointsPlugin use JointController.hh
so i try o make another one to the links but i am still looking for another classes that can do it from gazebo like Model Class or Link Calss part of
http://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/classgazebo_1_1physics_1_1Link.html http://osrf-distributions.s3.amazonaws.com/gazebo/api/dev/classgazebo_1_1physics_1_1Model.html
that have usefull funcations as : void SetAngularAccel (const ignition::math::Vector3d &_vel) GAZEBO_DEPRECATED(9.0) Set the angular acceleration of the model, and all its links. More...
void SetAngularVel (const ignition::math::Vector3d &_vel) Set the angular velocity of the model, and all its links. More...
void SetAnimation (const common::PoseAnimationPtr &_anim, boost::function< void()> _onComplete) Set an animation for this entity. More...
void SetAnimation (common::PoseAnimationPtr _anim) Set an animation for this entity. More...
i hope that my answer was usefull .
Asked by AlberSaber on 2018-11-14 04:35:16 UTC
Comments