Skip to content

Commit 8992f67

Browse files
committed
Add state checks on config variables
1 parent 4977993 commit 8992f67

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed

libraries/YarpPlugins/BasicCartesianControl/DeviceDriverImpl.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,50 @@ bool BasicCartesianControl::open(yarp::os::Searchable& config)
3838
return false;
3939
}
4040

41+
if (m_controllerGain < 0.0)
42+
{
43+
yCError(BCC) << "Controller gain must be positive";
44+
return false;
45+
}
46+
47+
if (m_trajectoryDuration < 0.0)
48+
{
49+
yCError(BCC) << "Trajectory duration must be positive or zero";
50+
return false;
51+
}
52+
else if (m_trajectoryDuration == 0.0)
53+
{
54+
yCInfo(BCC) << "Duration set to zero, therefore trajectory execution time will depend on reference speed and acceleration";
55+
}
56+
else
57+
{
58+
yCInfo(BCC) << "Trajectory duration forced to" << m_trajectoryDuration << "seconds regardless of velocity profile";
59+
}
60+
61+
if (m_trajectoryRefSpeed <= 0.0)
62+
{
63+
yCError(BCC) << "Trajectory reference speed must be positive";
64+
return false;
65+
}
66+
67+
if (m_trajectoryRefAccel <= 0.0)
68+
{
69+
yCError(BCC) << "Trajectory reference acceleration must be positive";
70+
return false;
71+
}
72+
73+
if (m_cmcPeriodMs <= 0)
74+
{
75+
yCError(BCC) << "CMC period must be positive";
76+
return false;
77+
}
78+
79+
if (m_waitPeriodMs <= 0)
80+
{
81+
yCError(BCC) << "Wait period must be positive";
82+
return false;
83+
}
84+
4185
yarp::os::Property robotOptions;
4286
robotOptions.fromString(config.toString());
4387
robotOptions.put("device", m_robot);

libraries/YarpPlugins/BasicCartesianControl/ICartesianControlImpl.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,17 @@ bool BasicCartesianControl::setParameter(int vocab, double value)
600600
yCError(BCC) << "Trajectory duration cannot be negative";
601601
return false;
602602
}
603+
else if ((m_trajectoryDuration == 0.0) ^ (value == 0.0))
604+
{
605+
if (value == 0.0)
606+
{
607+
yCInfo(BCC) << "Duration set to zero, therefore trajectory execution time will depend on reference speed and acceleration";
608+
}
609+
else
610+
{
611+
yCInfo(BCC) << "Trajectory duration forced to" << value << "seconds regardless of velocity profile";
612+
}
613+
}
603614
m_trajectoryDuration = value;
604615
break;
605616
case VOCAB_CC_CONFIG_TRAJ_REF_SPD:

0 commit comments

Comments
 (0)