Vrep to generate trajectory edit

Hi all, i'm new in ros and i'm trying to move my simulated UR10 in gazebo. What i'm doing is setting up the same scene in Vrep (now CoppeliaSim), where also i generate a set of points of my target trajectory, composed by 6*300=1800 points(each joint has 300 points to follow). I also have a jointTrajectoryController and the related actions. Is there a way to move my simulated robot using this points? I suppose Vrep has to publish some message to the /follow_joint_trajectory/goal topic but i have some problem understanding how to compose the message to publish. Tell me if i'm wrong, but i suppose i can't just copy and paste this 1800 points in the "Points" field of the action message. I also tried something really terrible using 6 differents JointPositionController, one for each joint, and sending them alternately the point to reach through the /command topic, something like this pseudocode:

for i=1,1800,1 do
publish(controller[i%6 +1],points[i])
end


I can't use only the last point, i want to follow the exact same trajectory vrep generated.

edit retag close merge delete

Sort by » oldest newest most voted

I suppose Vrep has to publish some message to the /follow_joint_trajectory/goal topic but i have some problem understanding how to compose the message to publish.

Provided you are using ur_gazebo (or a similar package) which exposes a FollowJointTrajectory action server, you'd have to write something that instantiates and populates a control_msgs/FollowJointTrajectory goal and then submits it to the action server.

The goal is not that difficult to create. Something like this would do it:

from control_msgs.msg import FollowJointTrajectoryAction, FollowJointTrajectoryGoal
from trajectory_msgs.msg import JointTrajectory, JointTrajectoryPoint

...

# using the action namespace you mentioned in your question here
client = actionlib.SimpleActionClient('follow_joint_trajectory', FollowJointTrajectoryAction)
client.wait_for_server()

goal = FollowJointTrajectoryGoal()
goal.trajectory = JointTrajectory()

# NOTE: order matters here! This HAS to correspond to how the
#       values in your VREP trajectory are ordered
goal.trajectory.joint_names = [
'shoulder_pan_joint',
'shoulder_lift_joint',
'elbow_joint',
'wrist_1_joint',
'wrist_2_joint',
'wrist_3_joint'
]

# not entirely sure how your 'points' list (array?) is built up. I'm
# assuming a list of tuple(float, float, float, float, float, float)

for p in points:
goal.trajectory.points.append(
JointTrajectoryPoint(
positions=list(p),
velocities=...,
accelerations=...,
effort=...,
time_from_start=rospy.Duration(...)))

# finally: submit the goal for execution
client.send_goal(goal)

# optional
client.wait_for_result()


You'll want to make sure to specify proper velocities, as I expect the controller to stop at each point in your trajectory if you don't.

more
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 1, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "math_score": 0.16712695360183716, "perplexity": 3000.3871492636486}, "config": {"markdown_headings": false, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "plain"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "warc_path": "s3://commoncrawl/crawl-data/CC-MAIN-2021-39/segments/1631780055632.65/warc/CC-MAIN-20210917090202-20210917120202-00635.warc.gz"}