Ask Your Question
0

Publishing Joint trajectory for robotic arm

asked 2016-07-11 22:15:31 -0500

suvrat13 gravatar image

updated 2016-07-12 01:10:29 -0500

gvdhoorn gravatar image

I have been working on simple publisher for joint trajectory before moving to joint trajectory action client. However on running the node i get an error saying:

malloc(): memory corruption: 0x0000000000c28eb0 *** Aborted (core dumped)

I tried finding a solution online but nothing seems to be of any help. I would appreciate if you could help me with the same.

Following is the code:

#include <ros/ros.h>
#include <trajectory_msgs/JointTrajectory.h>

int main(int argc, char **argv)
{
ros::init(argc, argv, "path_plan");
ros::NodeHandle node;

ROS_INFO("path_plan node started");

ros::Publisher pub = node.advertise<trajectory_msgs::JointTrajectory>("/cyton_joint_trajectory_action_controller/command", 1000);

ros::Rate rate(10);
rate.sleep();


while (ros::ok())
{

trajectory_msgs::JointTrajectory traj;

traj.joint_names.push_back("shoulder_roll_joint");
traj.joint_names.push_back("shoulder_pitch_joint");
traj.joint_names.push_back("elbow_roll_joint");
traj.joint_names.push_back("elbow_pitch_joint");
traj.joint_names.push_back("elbow_yaw_joint");
traj.joint_names.push_back("wrist_pitch_joint");
traj.joint_names.push_back("wrist_roll_joint");
traj.joint_names.push_back("gripper_joint");

// trajectory_msgs::JointTrajectoryPoint points; 

traj.points.resize(2);

int ind = 0;
traj.points[ind].positions.resize(8);
traj.points[ind].positions[0] = 0.0;
traj.points[ind].positions[1] = 0.0;
traj.points[ind].positions[2] = 0.0;
traj.points[ind].positions[3] = 0.0;
traj.points[ind].positions[4] = 0.0;
traj.points[ind].positions[5] = 0.0;
traj.points[ind].positions[6] = 0.0;
traj.points[ind].positions[7] = 0.7;
// Velocities
traj.points[ind].velocities.resize(8);
for (size_t j = 0; j < 8; ++j)
{
traj.points[ind].velocities[j] = 0.0;
}
// To be reached 1 second after starting along the traj
traj.points[ind].time_from_start = ros::Duration(1.0);

// Second trajectory point
// Positions
ind += 1;
traj.points[ind].positions.resize(7);
traj.points[ind].positions[0] = -0.3;
traj.points[ind].positions[1] = 0.2;
traj.points[ind].positions[2] = -0.1;
traj.points[ind].positions[3] = -1.2;
traj.points[ind].positions[4] = 1.5;
traj.points[ind].positions[5] = -0.3;
traj.points[ind].positions[6] = 0.5;
traj.points[ind].positions[7] = -0.7;
// Velocities
traj.points[ind].velocities.resize(8);
for (size_t j = 0; j < 8; ++j)
{
traj.points[ind].velocities[j] = 0.0;
}
// To be reached 2 seconds after starting along the traj
traj.points[ind].time_from_start = ros::Duration(2.0);


traj.header.stamp = ros::Time::now() + ros::Duration();

pub.publish(traj);

rate.sleep();
}


return 0;
}

Thanks!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-03-06 08:45:57 -0500

saurabh gravatar image

updated 2018-03-06 08:52:04 -0500

Just an observation in your code. Have you tried something like below:

traj.joint_names.resize(2);

traj.joint_names[0]("shoulder_roll_joint");

traj.joint_names[1]("shoulder_pitch_joint");

traj.joint_names[2]("elbow_roll_joint");

traj.joint_names[3]("elbow_pitch_joint");

traj.joint_names[4]("elbow_yaw_joint");

traj.joint_names[5]("wrist_pitch_joint");

traj.joint_names[6]("wrist_roll_joint");

traj.joint_names[7]("gripper_joint");

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-07-11 22:15:31 -0500

Seen: 694 times

Last updated: Mar 06 '18