浏览代码

Updated to use new message names

/laurie-Ros2Update
LaurieCheers 3 年前
当前提交
2d4f751f
共有 3 个文件被更改,包括 11 次插入14 次删除
  1. 3
      tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs
  2. 6
      tutorials/pick_and_place/Scripts/SourceDestinationPublisher.cs
  3. 16
      tutorials/pick_and_place/Scripts/TrajectoryPlanner.cs

3
tutorials/pick_and_place/PickAndPlaceProject/Assets/DemoScripts/Demo.cs


string rosConnectName = "ROSConnect";
string publisherName = "Publisher";
int hostPort = 10000;
int unityPort = 5005;
int awaitDataMaxRetries = 10;
int awaitDataSleepSeconds = 1;
string trajectoryPlannerType = "TrajectoryPlanner";
string rosServiceName = "niryo_moveit";

6
tutorials/pick_and_place/Scripts/SourceDestinationPublisher.cs


public void Publish()
{
MNiryoMoveitJoints sourceDestinationMessage = new MNiryoMoveitJoints();
NiryoMoveitJointsMsg sourceDestinationMessage = new NiryoMoveitJointsMsg();
sourceDestinationMessage.joint_00 = jointArticulationBodies[0].xDrive.target;
sourceDestinationMessage.joint_01 = jointArticulationBodies[1].xDrive.target;

sourceDestinationMessage.joint_05 = jointArticulationBodies[5].xDrive.target;
// Pick Pose
sourceDestinationMessage.pick_pose = new MPose
sourceDestinationMessage.pick_pose = new PoseMsg
{
position = target.transform.position.To<FLU>(),
orientation = Quaternion.Euler(90, target.transform.eulerAngles.y, 0).To<FLU>()

sourceDestinationMessage.place_pose = new MPose
sourceDestinationMessage.place_pose = new PoseMsg
{
position = targetPlacement.transform.position.To<FLU>(),
orientation = pickOrientation.To<FLU>()

16
tutorials/pick_and_place/Scripts/TrajectoryPlanner.cs


/// Get the current values of the robot's joint angles.
/// </summary>
/// <returns>NiryoMoveitJoints</returns>
MNiryoMoveitJoints CurrentJointConfig()
NiryoMoveitJointsMsg CurrentJointConfig()
MNiryoMoveitJoints joints = new MNiryoMoveitJoints();
NiryoMoveitJointsMsg joints = new NiryoMoveitJointsMsg();
joints.joint_00 = jointArticulationBodies[0].xDrive.target;
joints.joint_01 = jointArticulationBodies[1].xDrive.target;

/// </summary>
public void PublishJoints()
{
MMoverServiceRequest request = new MMoverServiceRequest();
MoverServiceRequest request = new MoverServiceRequest();
request.pick_pose = new MPose
request.pick_pose = new PoseMsg
{
position = (target.transform.position + pickPoseOffset).To<FLU>(),
// The hardcoded x/z angles assure that the gripper is always positioned above the target cube before grasping.

// Place Pose
request.place_pose = new MPose
request.place_pose = new PoseMsg
ros.SendServiceMessage<MMoverServiceResponse>(rosServiceName, request, TrajectoryResponse);
ros.SendServiceMessage<MoverServiceResponse>(rosServiceName, request, TrajectoryResponse);
void TrajectoryResponse(MMoverServiceResponse response)
void TrajectoryResponse(MoverServiceResponse response)
{
if (response.trajectories.Length > 0)
{

/// </summary>
/// <param name="response"> MoverServiceResponse received from niryo_moveit mover service running in ROS</param>
/// <returns></returns>
private IEnumerator ExecuteTrajectories(MMoverServiceResponse response)
private IEnumerator ExecuteTrajectories(MoverServiceResponse response)
{
if (response.trajectories != null)
{

正在加载...
取消
保存