Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
BOOK: Professional Microsoft Robotics Studio ISBN: 978-0-470-14107-6
This is the forum to discuss the Wrox book Professional Microsoft Robotics Developer Studio by Kyle Johns, Trevor Taylor; ISBN: 9780470141076
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional Microsoft Robotics Studio ISBN: 978-0-470-14107-6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old January 27th, 2010, 12:16 PM
Registered User
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Chaper 8 sample code


I'm not sure but I believe there is a mistake in the sample code of chapter 8.

The generic arm service has a state member called Joints.
The corresponding ArmGetHandler is registered as concurrent but inside you are changing the Joint member of the state.

I thought that you may not alter the state inside a concurrent service method. Is this right or should I read the book again?


PS: involved code sections:

inside the service start method:
// Add the winform message handler to the interleave
MainPortInterleave.CombineWith(new Interleave(
new TeardownReceiverGroup(),
new ExclusiveReceiverGroup( //some exclusive receivers ),
new ConcurrentReceiverGroup
Arbiter.ReceiveWithIterator<armproxy.Subscribe>(tr ue, _armPort, SubscribeHandler),
Arbiter.ReceiveWithIterator<armproxy.GetEndEffecto rPose>(true, _armPort, GetEndEffectorHandler),
Arbiter.Receive<DsspDefaultLookup>(true, _armPort, DefaultLookupHandler),
Arbiter.ReceiveWithIterator<armproxy.Get>(true, _armPort, ArmGetHandler)

/// <summary>
/// Get Handler
/// </summary>
/// <param name="get"></param>
/// <returns></returns>
/// <remarks>Get handler for Generic Arm contract</remarks>
public virtual IEnumerator<ITask> ArmGetHandler(armproxy.Get get)
// Update the state first with the current joint info
float baseAngle = 0, shoulder = 0, elbow = 0, wrist = 0;
float rotate = 0, gripper = 0;
if (_l6Arm != null)
// Get the target joint angles for all joints
// removed some irrelevant lines

// Put the values into the state
_state.Joints[0].State.Angular.DriveTargetOrientation = AngleToOrientationQuaternion(baseAngle);
_state.Joints[1].State.Angular.DriveTargetOrientation = AngleToOrientationQuaternion(shoulder);
_state.Joints[2].State.Angular.DriveTargetOrientation = AngleToOrientationQuaternion(elbow);
_state.Joints[3].State.Angular.DriveTargetOrientation = AngleToOrientationQuaternion(wrist);
_state.Joints[4].State.Angular.DriveTargetOrientation = AngleToOrientationQuaternion(rotate);
_state.Joints[5].State.Angular.DriveTargetOrientation = AngleToOrientationQuaternion(gripper);
// Return the state
yield break;
Old January 29th, 2010, 03:53 AM
Wrox Author
Join Date: Apr 2008
Location: Brisbane, QLD, Australia.
Posts: 60
Thanks: 0
Thanked 5 Times in 5 Posts
Default Exclusive versus Concurrent

Interesting question. This is a Get handler, so by definition it should normally be Concurrent. However, you are also correct that any handler that modifies the State should be Exclusive.

I didn't write the code, but I think that what is happening is that the current joint values are being retrieved and placed into the state so that it can be sent back. So the arm is not actually moving as a result of this. I'd have to look more closely to see what is going on.

Old January 29th, 2010, 05:42 AM
Registered User
Join Date: Jan 2010
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts

Yes the joint angles of the current position are copied to the service state. For my project I try need to do something similar to the sample in chapter8. Let me explain:

Currently I'm trying to create my own robot arm service and entity. This service will implement the generic articulated arm contract. Inside the service I have the service class (SimulatedRobotArmService) and the enitity class (SimulatedRobotArmEntity)

The ArticulatedArmState contains the property: "List<Joint> Joints" and also my entity contains a list of type joint to control the arm movement.

with the following line of code, I try to copy the joint list from the entity to the joint list from the state.
_state.Joints = _robotArm.Joints;

But this line of code will throw the following compile error:
Error 1 Cannot implicitly convert type 'System.Collections.Generic.List<Microsoft.Robotic s.PhysicalModel.Joint>' to 'System.Collections.Generic.List<Microsoft.Robotic s.PhysicalModel.Proxy.Joint>

I found out that because I'm implementing the generic articulated arm contract the state.Joints is from the proxy type. And the one from my entity that i use is from the non-proxy type. Is there any way to convert between them?

PS: I can upload a demo solution that contains my problem if there is a need for it.
Old February 14th, 2010, 01:28 AM
Wrox Author
Join Date: Apr 2008
Location: Brisbane, QLD, Australia.
Posts: 60
Thanks: 0
Thanked 5 Times in 5 Posts
Default Converting Proxy Types

I'm not the best person to answer this, but...

The Proxy should contain methods for converting to/from the internal types used in the entity. You can look at the Proxy code that is generated -- it is in the Proxy folder.

The only other alternative is to explicitly copy the Joints field by field.


Similar Threads
Thread Thread Starter Forum Replies Last Post
want sample code mohiddin52 Access VBA 2 December 16th, 2006 04:54 AM
I want to download sample code! caolei Pro JSP 6 May 26th, 2006 10:36 AM
Need Sample code okshilato SQL Server 2005 0 March 28th, 2006 10:41 AM
Sample Code mirouvor Java Databases 1 January 2nd, 2006 02:28 PM
Where the sample code? rbtcx BOOK: Professional C#, 2nd and 3rd Editions 5 August 21st, 2003 02:58 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.